BookmarkSubscribeRSS Feed
sas_
Fluorite | Level 6
Hi i am having 200 datasets with name like daily1--daily200 ,in each dataset there will be one date by name ins_date ,now i want to create a new dataset with all the dataset name and the ins_date and counts of obs in that datasets ,i want one row for each dataset like having datasetname,ins_date and count,the ins_date is the same for each entire dataset for ex:for dataset daily1 has ins_date is 01/01/2011 there will be no other date for it.

ex

Dset_name Ins_Date count
daily1 01/01/2011 135
daily2 02/01/2011 231
....

like that
3 REPLIES 3
ieva
Pyrite | Level 9
I think the easiest way could be collecting all data in one file and then running Proc Freq

%macro collect;

*add data set name in case you dont have it in data;

%do i=1 %to 200;
data daily&i.b;
set daily&i;
format dset_name $10.;
dset_name="daily&i";
run;
%end;

data total;
set %do j=1 %to 200;
daily&j.b (keep=dset_name ins_date)
%end;;
run;

%mend;
%collect;


proc freq data=total noprint ;
tables dset_name*ins_date/out=freq_table (drop=percent) ;
run;
sas_
Fluorite | Level 6
Thqs
Ksharp
Super User
Maybe you can code like ,Not tested.
[pre]






data temp;
set sashelp.vtable(where=(libname='WORK') keep=memname nobs);
if memname eq: 'DAILY';
run;

options obs=1;
data want;
set daily1 - daily200 indsname=dsn;
memname=scan(dsn,2,'.');
run;

data want;
merge want temp;
by memname;
run;
[/pre]


Ksharp

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1314 views
  • 0 likes
  • 3 in conversation