BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
nd
Obsidian | Level 7 nd
Obsidian | Level 7

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If you want a new variable in the data set then add:

 

Newvar = catx(' ',x1,x2);

before the output statement.

View solution in original post

4 REPLIES 4
ballardw
Super User

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

 

nd
Obsidian | Level 7 nd
Obsidian | Level 7

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. 

 

ballardw
Super User

If you want a new variable in the data set then add:

 

Newvar = catx(' ',x1,x2);

before the output statement.

nd
Obsidian | Level 7 nd
Obsidian | Level 7

Thank you! 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is ANOVA?

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.

Discussion stats
  • 4 replies
  • 778 views
  • 0 likes
  • 2 in conversation