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
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;
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...
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;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.