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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 487 views
  • 0 likes
  • 3 in conversation