Hi,
I have a dataset with columns - User_id Condition1 Condition 9 Condition 11....... Condition 102
I want to perform array functions, is there any way to declare conditions as an array? The problem is the numbers aren't uniform, ie, it isn't Condition1, Condition2, Condition3 and so on.
I was thinking something like:
array conds{*} condition: ;
But it didn't work.
Thanks.
Hi @rdum96
You can use the form
array c $ cond:;
The colon after cond covers all variables beginning with cond. They must be same type, numeric or character. If they are char the $ sign is needed.
Hi @rdum96
You can use the form
array c $ cond:;
The colon after cond covers all variables beginning with cond. They must be same type, numeric or character. If they are char the $ sign is needed.
If the variables already exist the $ in the array is not needed:
data _null_; set sashelp.class (obs=1); array c name sex; do i=1 to dim(c); put "Value is: " c[i]; end; run;
Log shows:
121 data _null_; 122 set sashelp.class (obs=1); 123 array c name sex; 124 do i=1 to dim(c); 125 put "Value is: " c[i]; 126 end; 127 run; Value is: Alfred Value is: M NOTE: There were 1 observations read from the data set SASHELP.CLASS. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
No warnings or anything, output as expected.
I would not say "do not add the $", just saying not required.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.