If your actual values are sequential integers (not stated, what you show might be character values as "categorical" is a usage not variable type )
data want; do x1 = 1 to 3; do x2 = 1 to 2; do x3 = 1 to 2; do x4 = 1 to 3; do x5 = 1 to 2; do x6 = 1 to 3; do x7 = 1 to 4; do x8 = 1 to 2; do x9 = 1 to 3; output; end; end; end; end; end; end; end; end; end; run;
If your values are not actually sequential for a given variable then use a list of values for the do: do x= 2,5,27; or what have you. Same for character values.
Note I didn't bother to indent the code for each level of the DO because that many nested indents can get rendered pretty ugly with tabs set at anything more than 2 or 3 spaces.
The code needed to do anything like this with differing numbers of values for each variable would be extremely ugly attempting to use any of the combinatoric functions like ALLCOMB .
Or maybe you could try to write something yourself, and then, in case of problems, ask? 😉
Bart
Are you trying to analyze something or just wanting to create data?
This will assist in determining the best route;
cartesian join vs cross-tabulation, pivot table?
If your actual values are sequential integers (not stated, what you show might be character values as "categorical" is a usage not variable type )
data want; do x1 = 1 to 3; do x2 = 1 to 2; do x3 = 1 to 2; do x4 = 1 to 3; do x5 = 1 to 2; do x6 = 1 to 3; do x7 = 1 to 4; do x8 = 1 to 2; do x9 = 1 to 3; output; end; end; end; end; end; end; end; end; end; run;
If your values are not actually sequential for a given variable then use a list of values for the do: do x= 2,5,27; or what have you. Same for character values.
Note I didn't bother to indent the code for each level of the DO because that many nested indents can get rendered pretty ugly with tabs set at anything more than 2 or 3 spaces.
The code needed to do anything like this with differing numbers of values for each variable would be extremely ugly attempting to use any of the combinatoric functions like ALLCOMB .
Or more simply:
proc plan;
factors x1=3 ordered x2=2 ordered x3=2 ordered x4=3 ordered x5=2 ordered
x6=3 ordered x7=4 ordered x8=2 ordered x9=3 ordered / noprint;
output out=plan;
run;
Remove the ORDERED keywords if you want selections to be random.
Your PROC PLAN is just creating a Cartesian Product, just like the following PROC SQL.
proc sql;
create table want as
select * from
have(keep=x1),
have(keep=x2),
have(keep=x3),
have(keep=x4),
have(keep=x5),
have(keep=x6),
have(keep=x7),
have(keep=x8),
have(keep=x9)
quit;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.