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.
1 ACCEPTED SOLUTIONYou can use the form
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.
3 REPLIES 3 Rhodochrosite | Level 12You can use the form
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.
Calcite | Level 5If 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;
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.