BookmarkSubscribeRSS Feed
Sean_OConnor
Obsidian | Level 7

I have the following two datasteps with the first one stacking various datasets together and the second part extracting records and putting them into datasets depending on the month.

 

*Step 1 
data temps.full_clean;
	set temps.clean_:
run;
*Step 2
data  temps.nov_21 temps.dec_21 temps.jan_22;
	set temps.full_clean;
	select (paydate_monthyear);
		when ("202111") output temps.nov_21;
		when ("202112") output temps.dec_21;
		when ("202201") output temps.jan_22;
		otherwise;
	end;
run;

One of the issues is when I stack the datasets in the location temps. clean_: to create temps.full_clean it creates a rather large SAS dataset which takes up a lot of space.

What I would like to do is search individually through temps.clean_1 temps.clean_2 temps.clean_3..... and output all records to temps.nov_21 if the criteria in step 2 is met, then look at temps.clean_2 and update temps.nov_21 with the additional records.

 

I would like to carry this out for the various different months.

 

Does anyone know an easy way to do this which would result in me not having to create a large temps.full_clean dataset?

1 REPLY 1
SASJedi
Ammonite | Level 13

If the code you show is producing the result you want, you can skip the first DATA step by using the first DATA step's SET statement in the second DATA step, something like this:

data  temps.nov_21 temps.dec_21 temps.jan_22;
	set temps.clean_:
	select (paydate_monthyear);
		when ("202111") output temps.nov_21;
		when ("202112") output temps.dec_21;
		when ("202201") output temps.jan_22;
		otherwise;
	end;
run;
Check out my Jedi SAS Tricks for SAS Users

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 633 views
  • 2 likes
  • 2 in conversation