BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

Hello

Let's say that I have a series multiple  data sets .

The name of a typical  data set  is : RawTbl&date.
I  want to create a data set with one column called date that will contain values of all datasets names (date only)

For example:

Let's say that there are 5 data sets called:

RawTbl28012019

RawTbl15032019

RawTbl15061819

RawTbl27062019

RawTbl13082019

 

then in the created data set will be values:

28012019

15032019

15061819

27062019

13082019

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Another way to achieve this, assuming the entry datasets are SAS datasets:

 

proc contents data=work._all_  noprint out=content (keep= memname where=(substr(upcase(memname),1,6) = 'RAWTBL'));
run;

data want;
	set content;
	length date $8.;
	date = substr(memname,7,8);
	keep date;
run;

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

I assume you mean (but you should really be more clear here) that these multiple data set are SAS data sets.

 

Then you can use the SET statement with the INDSNAME option to obtain a variable that includes the names of the SAS data sets used to produce each observation. https://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=p00hxg3x8lwivcn1f0e9axziw57y.htm&doc...

--
Paige Miller
ed_sas_member
Meteorite | Level 14

Hi @Ronein 

 

You can try this:

proc sql;
	create table want as 
	select distinct substr(memname,7,8) as date
	from dictionary.tables
	where libname = "WORK" and upcase(substr(memname,1,6)) = "RAWTBL";
quit;
ed_sas_member
Meteorite | Level 14

Another way to achieve this, assuming the entry datasets are SAS datasets:

 

proc contents data=work._all_  noprint out=content (keep= memname where=(substr(upcase(memname),1,6) = 'RAWTBL'));
run;

data want;
	set content;
	length date $8.;
	date = substr(memname,7,8);
	keep date;
run;

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!

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