BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Aexor
Lapis Lazuli | Level 10

Need inputs in below query:

 

We want a smaller dateset from a huge dateset(having 10000 variable) based on a condition , and also creating a new variable.

What are options and statements you are going to prefer ?

and out of 10000 variables we need few only.

 

Please suggest

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Generally best not to do this, turning one large data set into 4 or 5 smaller ones is not a good thing to do, unless you have a very good reason.

 

Using SASHELP.CLASS as an example, you can use portions of the data set as needed, without creating separate data sets.

 

proc print data=sashelp.class(where=(sex='M'));
run;

proc print data=sashelp.class(where=(sex='F'));
run;

 

--
Paige Miller

View solution in original post

6 REPLIES 6
Aexor
Lapis Lazuli | Level 10

How can we create 4 to 5  datasets , based on different condition in single code ?

PaigeMiller
Diamond | Level 26

Generally best not to do this, turning one large data set into 4 or 5 smaller ones is not a good thing to do, unless you have a very good reason.

 

Using SASHELP.CLASS as an example, you can use portions of the data set as needed, without creating separate data sets.

 

proc print data=sashelp.class(where=(sex='M'));
run;

proc print data=sashelp.class(where=(sex='F'));
run;

 

--
Paige Miller
Reeza
Super User
The general recommendation in SAS is to not split data sets. The BY group processing typically makes this very unnecessary and it also requires a lot more work/effort if you do.

https://blogs.sas.com/content/sgf/2020/07/23/splitting-a-data-set-into-smaller-data-sets/
PaigeMiller
Diamond | Level 26

Please be more specific about the condition regarding how to choose the records that wind up in the output data set.

 

Please provide a portion of the large data set following these instructions, and not via any other method.

--
Paige Miller
Reeza
Super User
HW or test for a job?
andreas_lds
Jade | Level 19

I have merged both posts.

 

What does "huge" mean? Give some numbers!

And having 10k variables is a design-fault, so fix that problem during creation of the dataset, not afterwards.

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1662 views
  • 3 likes
  • 4 in conversation