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

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!

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.

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