BookmarkSubscribeRSS Feed
bayoote
Calcite | Level 5

Group

ProductConditionY     
Group 1A10-2     
Group 1A10-1     
Group 1A200     
Group 1A201     
Group 1A202     
Group 1A30-19.5     
Group 1A30-18     
Group 1A30-16.5     
Group 1A30-15     
Group 1B10-14     
Group 1B10-13     
Group 1B20-12     
Group 1B20-11     
Group 1B20-10     
Group 1B30-9     
Group 1B30-8     
Group 1B30-7     
Group 1B30-6     
Group 2A10-2     
Group 2A10-1     
Group 2A200     
Group 2A201     
Group 2A202     
Group 2A30-19.5     
Group 2A30-18     
Group 2A30-16.5     
Group 2A30-15     
Group 2B10-14     
Group 2B10-13     
Group 2B20-12     
Group 2B20-11     
Group 2B20-10     
Group 2B30-9     
Group 2B30-8     
Group 2B30-7     
Group 2B30-6     

Hi All,

 

Part of my datasets is like above and I want to split my dataset into multiple dataset based on group, product and condition.

 
For example:       
my first data set will be:      
Group 1A-2      
Group 1A-1      
         
my second data set will be:      
         
Group 1A0      
Group 1A1      
Group 1A2      
         
How can I achieve that?      
         
Thanks!        
         
         
         
2 REPLIES 2
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10

I think you want to use the DATA step and output more than one table. You just need to find the right statements with the correct conditional logic. The following example might work as long as Y has no missing values--remember a missing value in SAS is actually a negative number (tiny, but still a value). 

 

Data First Second;
   Set Have;
 if Group = 'Group 1' and Product = 'A' and Y < 0 then output First;
 else if Group = 'Group 1' and Product = 'A' and Y >= 0 then output Second;
Run;

 

andreas_lds
Jade | Level 19
Why do you want to split your dataset? There is hardly any good reason to do so, except the daraset is to large to use normal group-by processing.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 633 views
  • 0 likes
  • 3 in conversation