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: 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!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 642 views
  • 1 like
  • 3 in conversation