Here's my code:
%put ParamList = &ParamList; data testing; array x[5] $10 (&ParamList); n=dim(x); k=2; ncomb=comb(n,k); do j=1 to ncomb+1 rc=lexCOMB(j, k, of x[*]); if rc<0 then delete; put j 5. +2 x1-x2; output; end; run;
where ParamList = "1-White" "2-Black" "3-Hispanic" "4-Asian" "5-Other"
The code outputs the following in the log:
1 1-White 2-Black
2 1-White 3-Hispanic
3 1-White 4-Asian
4 1-White 5-Other
5 2-Black 3-Hispanic
6 2-Black 4-Asian
7 2-Black 5-Other
8 3-Hispanic 4-Asian
9 3-Hispanic 5-Other
10 4-Asian 5-Other
How can I save these results in a SAS file? Thanks.
If you want a new variable in the data set then add:
Newvar = catx(' ',x1,x2);
before the output statement.
Did you look at the TESTING data set created?
The OUTPUT statement tells SAS to write the variables to the data set when encountered.
If you compare the values of the X1 and X2 variables with your LOG output they should match.
HOWEVER, your code as posted is missing a semicolon at the end of the
do j=1 to ncomb+1
The missing semicolon is a typo, my saved code has it.
Attached is the TESTING dataset. What I want is one column with the results "1-White 2-Black", "1-White 3-Hispanic," etc. Thanks.
If you want a new variable in the data set then add:
Newvar = catx(' ',x1,x2);
before the output statement.
Thank you!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.