sas

Generate All Unique Permutations of an Array in SAS

半城伤御伤魂 提交于 2021-02-07 14:36:01
问题 In SAS if I have a string or an Array like the following, array x[4] $1 ('A' 'B' 'C' 'D'); I need to generate all "Unique" permutations of the elements like the following, [ABCD] [ABC] [BCD] [ACD] [ABD] [AB] [AC] [AD] [BC] [BD] [CD] [A] [B] [C] [D] Is there a function in SAS for generating all possible combinations of the array? 回答1: Assumption : I believe you are looking for combinations and not permutations , so the order does not matter, BA and AB are same thing. Use call allcomb

IF-THEN vs IF in SAS

∥☆過路亽.° 提交于 2021-02-07 13:20:31
问题 What is the difference between IF and IF-THEN For example the following statement if type='H' then output; vs if type='H'; output; 回答1: An if-then statement conditionally executes code. If the condition is met for a given observation, whatever follows the 'then' before the ; is executed, otherwise it isn't. In your example, since what follows is output , only observations with type 'H' are output to the data set(s) being built by the data step. You can also have an if-then-do statement, such

How to convert String to Date value in SAS?

倖福魔咒の 提交于 2021-02-07 03:11:09
问题 I want to convert a String to Date in SAS, I tried: data _null_; monyy = '05May2013'; date = input(substr(strip(monyy),1,9),yymmdd.);; put date=date9.; run; But it did not work. Can this be done? 回答1: You don't need substr or strip. input(monyy,date9.); 回答2: Formats like date9. or mmddyy10. are not valid for input command while converting text to a sas date. You can use Date = input( cdate , ANYDTDTE11.); or Date = input( cdate , ANYDTDTE10.); for conversion. 回答3: As stated above, the simple

How to convert String to Date value in SAS?

心不动则不痛 提交于 2021-02-07 03:10:17
问题 I want to convert a String to Date in SAS, I tried: data _null_; monyy = '05May2013'; date = input(substr(strip(monyy),1,9),yymmdd.);; put date=date9.; run; But it did not work. Can this be done? 回答1: You don't need substr or strip. input(monyy,date9.); 回答2: Formats like date9. or mmddyy10. are not valid for input command while converting text to a sas date. You can use Date = input( cdate , ANYDTDTE11.); or Date = input( cdate , ANYDTDTE10.); for conversion. 回答3: As stated above, the simple

How to convert String to Date value in SAS?

被刻印的时光 ゝ 提交于 2021-02-07 03:08:47
问题 I want to convert a String to Date in SAS, I tried: data _null_; monyy = '05May2013'; date = input(substr(strip(monyy),1,9),yymmdd.);; put date=date9.; run; But it did not work. Can this be done? 回答1: You don't need substr or strip. input(monyy,date9.); 回答2: Formats like date9. or mmddyy10. are not valid for input command while converting text to a sas date. You can use Date = input( cdate , ANYDTDTE11.); or Date = input( cdate , ANYDTDTE10.); for conversion. 回答3: As stated above, the simple

How to convert String to Date value in SAS?

瘦欲@ 提交于 2021-02-07 03:04:39
问题 I want to convert a String to Date in SAS, I tried: data _null_; monyy = '05May2013'; date = input(substr(strip(monyy),1,9),yymmdd.);; put date=date9.; run; But it did not work. Can this be done? 回答1: You don't need substr or strip. input(monyy,date9.); 回答2: Formats like date9. or mmddyy10. are not valid for input command while converting text to a sas date. You can use Date = input( cdate , ANYDTDTE11.); or Date = input( cdate , ANYDTDTE10.); for conversion. 回答3: As stated above, the simple

Connect SAS to a Microsoft SQL Server database

…衆ロ難τιáo~ 提交于 2021-01-29 16:03:00
问题 I'd like to connect SAS to a Microsoft SQL Server database but I didn't succeed. I already have a database connection using a NT authentication. For instance, when I want to connect R (the statistical sofware) to the db, I do that ch_db <- odbcConnect("sql_nt") But when I do that in SAS, it doesn't work : LIBNAME sql ODBC DSN=’sql_nt’; I have this error message : ERROR: Libname SQL is not assigned. ERROR: Error in the LIBNAME statement. ERROR 22-7: Invalid option name SQL_NT. I probably do a

Transforming expansive “Check all that apply” type questions into random selection of lesser items

孤者浪人 提交于 2021-01-29 15:57:24
问题 I have been facing some difficulties in managing dietary data regarding cereal consumption. The question allows participants to select as many cereal types that they eat (among 300+ choices). I would like to collapse this into just two answers through random selection. The data structure is posing problems. I will outline my problem below… 1.) Structure of the data now: Respondents are allowed to select all cereals that they “usually” eat. The data looks like (1 is replaced with a code for

How to tricky rank SAS?

微笑、不失礼 提交于 2021-01-29 15:09:02
问题 SO For example I have data like this, KEY first count 11Y 1 11Y 2 11N 3 11N 4 11Y 5 11N 6 I want out put like this KEY first count RANKS 11Y 1 1 11Y 2 1 11N 3 2 11N 4 2 11Y 5 3 11N 6 4 how can I do in SAS? Thanks I did this proc sort data=step3; by first_count key; run; data step4; set step3; by key; if first.key THEN ranks=1; else ranks+1; run; This causing error ERROR: BY variables are not properly sorted on data set WORK.STEP3 回答1: You need NOTSORTED. data key; input KEY:$3. count; cards;

Covert wide to long in sas when all the variable has the suffix needed

谁都会走 提交于 2021-01-29 14:41:57
问题 I want the first wide dataset to be as the second long datafile, I have thought about using array, but considering I have 100 variables (the example only have 2), do I need 100 arrays? Could you let me know how to do? 回答1: Use a double transpose. First transpose to a tall structure. Then split the name into the basename and time. Then transpose again. Here is untested code since no example data was provided (only photographs). proc transpose data=have out=tall ; by id; var _numeric_; run;