I am creating multiple datasets from one dataset using the following code. Do I have list all the 23 dataset names. Is ther way like a1-a23 (this didnot work) i can use to simplify. Thanks.
data a1 a2 a3 a4 a5 a6 a7 to a23;
set b;
if then do;
end;
output a1;
end;
run;
If you want to do it that way, then yes you do have to list it out. There are other ways, but the general advice is don't do this.
Your posted code isn't correct, but I'm assuming you have more data somewhere.
http://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/
And here:
Unfortunately what you are doing pretty much requires an exact list.
There are some methods to generate lists. One might ask the need for splitting one data set that many ways. Since you are going to have 23 conditions to output the data I wouldn't worry so much about this list of sets.
It may be that your later data processing could use the concept of BY where it will do the same thing for each value of a variable in your data.
This example may help:
data teams;
input team$;
cards;
TeamA
TeamA
TeamA
TeamB
TeamB
TeamB
;
data _null_;
set teams;
by team;
if first.team then do;
call execute("data "||team||";");
call execute ("set teams (where=(team ='"||strip(team)||"')); run;");
end;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.