Hi,
I have 50+ data sets having different lengths with date extension, I want to read only date part from data sets and store in a variable for time stamp.
pls advise me how to read date part from data set name.
TEST_201312.sas7bdat
TEST__MONTH_201312.sas7bdat
TEST__YEAR_201312.sas7bdat
USE scan() with delimiter _. and -2 as counter so extracting second last substring.
Please try the below code
data TEST_201312;
test=1;
run;
data TEST__MONTH_201312;
test=1;
run;
data TEST__YEAR_201312;
test=1;
run;
proc sql;
create table tab as select memname, cats(put(input(substr(left((compress(memname,,'kd'))),5,2),best.),monname3.),substr(left((compress(memname,,'kd'))),1,4)) as month_year from dictionary.tables where upcase(memname) like "TEST%";
quit;
output:
Thanks,
Jag
Where do want the new variable to go? You seem to imply you want the new variable in each data set.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.