sas

Date conversion in SAS (String to Date)

混江龙づ霸主 提交于 2021-01-29 13:45:31
问题 I import an Excel-spreadsheet using the following SAS-procedure. %let datafile = 'Excel.xlsx' %let tablename = myDB proc import datafile = &datafile out = &tablename dbms = xlsx replace ; run; One of the variables ( date_variable ) has the format DD.MM.YYYY. Therefore, I was defining a new format like this: data &tablename; set &tablename; format date_variable mmddyy10.; run; Now, I would like to sort the table by that variable: proc sort data = &tablename; by date_variable; run; However, as

extracting substring using regex in sas

蓝咒 提交于 2021-01-29 12:09:30
问题 I have a string like this: dfjkldjfdsldfkdslfkd dfkdjd/FR018/HAHDFKDLFDAFHDKFJL/ABCD//NAME/I WANT TO EXTRACT THIS/JJJJ//NAME/blah blah blah in this string, I want to be able to pull the string I WANT TO EXTRACT THIS . In other words, I want to extract everything that follows /ABCD//NAME/ and before /JJJJ . how can I write this using regular expressions? thanks 回答1: I am not familiar with SAS, but from the documentation it seems like you can do: re = prxparse('/\/ABCD\/\/NAME\/(.*?)\/(.*?)\

How do you add a row Number in SAS by multiple groups with one variable in decending order?

扶醉桌前 提交于 2021-01-29 09:28:40
问题 I have discovered this code in SAS that mimics the following window function in SQL server: ROW_NUMBER() OVER (PARTITION BY Var1,var2 ORDER BY var1, var2) = data want; set have by var1 var2; if first.var1 AND first.var2 then n=1; else n+1; run; "She's a beaut' Clark"... but, How does one mimic this operation: ROW_NUMBER() OVER (PARTITION BY Var1,var2 ORDER BY var1, var2 Desc) I've made sure I have before: PROC SORT DATA=WORK.TEST OUT=WORK.TEST; BY var1 DECENDING var2 ; RUN; data WORK.want;

SAS create a frequency of variable frequencies

萝らか妹 提交于 2021-01-29 09:07:57
问题 I would like to create a table that lists the frequency of each variables frequencies. For example, a data set with 100 rows and 4 variables: ID, A, B, and C. What I'm looking for would be like this: Freqs| ID A B C ---------------------------- 1 | 100 20 15 10 2 | 0 40 35 0 3 | 0 0 5 30 Since there are 100 unique IDs, there will be a frequency of 100 frequencies of 1 from the original data. edit for clarification: If you did a proc freq on the original data, you would get a frequency of 1

Download JSON File from API via Proxy using SAS EG

China☆狼群 提交于 2021-01-29 07:41:08
问题 I am trying to geocode adresses from within a company network using an API from the Swiss authorities. My company uses proxy servers with usernames and passwords. I am new to SAS EG and this is the code that I have so far (i had to anonymize some things in order to be allowed to post this here): filename response temp; options set=SSL_USE_SNI=1; options set=SSL_SNI_HOSTNAME="api3.geo.admin.ch"; proc http url = 'https://api3.geo.admin.ch/rest/services/api/SearchServer?searchText=Bahnhofstrasse

Odd behavior with SAS numeric comparison; precision issue?

纵然是瞬间 提交于 2021-01-28 11:36:38
问题 I'm running a simple inequality filter in SAS as follows: data my_data; set my_data; my_var = sum(parent_var1, -parent_var2) run; proc sql; select my_var format=32.32 from my_data where my_var < 0.02; quit; I get the following result: my_var .0200000000000000000000000000000 .0200000000000000000000000000000 .0200000000000000000000000000000 (etc...) The problem, in case it's not obvious, is that I want numbers below .02, but it looks very much like my number is .02. According to the properties

SAS date imported wrong

假装没事ソ 提交于 2021-01-28 10:51:03
问题 When I imported my excel sheet some dates imported differently than others. I tried to fix this with the code below to format the date. DATA volume; SET mice.volume; format Date MMDDYY10.; run; However, I received the following error. ERROR 48-59: The format $MMDDYY was not found or could not be loaded. I had also tried with the following code DATA volume; SET mice.volume; If date= 44138 then date= '11/3'; If date= 44141 then date= '11/6'; run; NOTE: Character values have been converted to

SAS date imported wrong

丶灬走出姿态 提交于 2021-01-28 10:49:35
问题 When I imported my excel sheet some dates imported differently than others. I tried to fix this with the code below to format the date. DATA volume; SET mice.volume; format Date MMDDYY10.; run; However, I received the following error. ERROR 48-59: The format $MMDDYY was not found or could not be loaded. I had also tried with the following code DATA volume; SET mice.volume; If date= 44138 then date= '11/3'; If date= 44141 then date= '11/6'; run; NOTE: Character values have been converted to

SAS TINV vs EXCEL TINV

拈花ヽ惹草 提交于 2021-01-27 18:54:50
问题 I am planning to convert an Excel code into SAS There is a function called TINV used in Excel, and the same function is also in SAS with the same syntax, but I am getting two different results for the same numbers. Please help me know if both are different functions or the same. SAS: TINV(0.95,2) Result: 2.9199855804 Excel: TINV(0.95,2) Result : 0.070799 回答1: Although these functions appear to have the same syntax, they differ in how the arguments are interpreted. It looks as though SAS uses

sas proc export errors

主宰稳场 提交于 2021-01-27 17:04:32
问题 I am trying to to use the proc export in SAS, and keep getting the same error: ERROR: Export unsuccessful. See SAS Log for details. NOTE: The SAS System stopped processing this step because of errors. Error creating XLSX file -> It is either not an Excel spreadsheet or it is damaged. Error code=8000101D Requested Output File is Invalid sadly, I can't understand the meaning of the error PROC EXPORT DATA=work.PANEL_SOFI OUTFILE= "c:\\user\eyal\work.new_panel.xlsx" DBMS=xlsx REPLACE ; SHEET=