BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

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;

 

4 REPLIES 4
Reeza
Super User

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:

 

http://www.sascommunity.org/wiki/Split_Data_into_Subsets

ballardw
Super User

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.

 

Steelers_In_DC
Barite | Level 11

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;

LinusH
Tourmaline | Level 20
You could use a macro approach with %do loops to generate data set nsmed and logic dynamic.
But I agree with @Reeza that splitting data usually is not benificial. Reporting and statistical analysis is supported best by bringing data together, not splitting them apart.
Data never sleeps

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1043 views
  • 1 like
  • 5 in conversation