BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
NewUsrStat
Pyrite | Level 9

Hi guys, 

I'm trying to remove all intermediate files that are created while running a script. 

However, I would like to retain only a specific one, the most important whose name is the following: myres1_1

 

I used the following: 


proc datasets lib=work;
save myres1_1;
quit;

 

What if I want to use a regex to specify the pattern "myres1*" instead of the full name? I have to concatenate many script so I cannot specify every time the name and hence the pattern will be useful.

Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

 

If you want to save all the data sets with common beginning characters then the : list modifier may be of interest. This would save all the data sets whose names start with Pat_  .

proc datasets library=work;
   save pat_:;
run;
quit;

 

You can also use a list name range. You haven't provided much detail as to what may exist but if the other data sets have names with the same base but different sequence numbers, assuming your _1 is a "sequence" then something like this would save myres1_2, myres1_3 ... myres1_9. Caveat: all of the sequence numbers from 2 through 9 (or what ever you want) have to exist for the list to work.

Proc datasets lib=work;
   save myres1_2 - myres1_9;
run;
quit;

 


@NewUsrStat wrote:

Hi guys, 

I'm trying to remove all intermediate files that are created while running a script. 

However, I would like to retain only a specific one, the most important whose name is the following: myres1_1

 

I used the following: 


proc datasets lib=work;
save myres1_1;
quit;

 

What if I want to use a regex to specify the pattern "myres1*" instead of the full name? I have to concatenate many script so I cannot specify every time the name and hence the pattern will be useful.

Thank you in advance


 

View solution in original post

3 REPLIES 3
yabwon
Onyx | Level 15

Use colon `:`

data myres1_1 myres1_2 ABC def ghi;
set sashelp.class;
run;

proc datasets lib=work;
save myres1_:;
quit;

Bart

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



ballardw
Super User

 

If you want to save all the data sets with common beginning characters then the : list modifier may be of interest. This would save all the data sets whose names start with Pat_  .

proc datasets library=work;
   save pat_:;
run;
quit;

 

You can also use a list name range. You haven't provided much detail as to what may exist but if the other data sets have names with the same base but different sequence numbers, assuming your _1 is a "sequence" then something like this would save myres1_2, myres1_3 ... myres1_9. Caveat: all of the sequence numbers from 2 through 9 (or what ever you want) have to exist for the list to work.

Proc datasets lib=work;
   save myres1_2 - myres1_9;
run;
quit;

 


@NewUsrStat wrote:

Hi guys, 

I'm trying to remove all intermediate files that are created while running a script. 

However, I would like to retain only a specific one, the most important whose name is the following: myres1_1

 

I used the following: 


proc datasets lib=work;
save myres1_1;
quit;

 

What if I want to use a regex to specify the pattern "myres1*" instead of the full name? I have to concatenate many script so I cannot specify every time the name and hence the pattern will be useful.

Thank you in advance


 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 795 views
  • 1 like
  • 3 in conversation