Help using Base SAS procedures

Reg:Date

Reply
Contributor
Posts: 66

Reg:Date

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
Frequent Contributor
Posts: 82

Re: Reg:Date

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;
Contributor
Posts: 66

Re: Reg:Date

Thqs
Super User
Posts: 10,028

Re: Reg:Date

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
Ask a Question
Discussion stats
  • 3 replies
  • 151 views
  • 0 likes
  • 3 in conversation