BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I need to create a summary report with all counts.So I created a count for each dataset and together put it on the one dataset,but the output is not so exact if I use the below code,

data summaryReport;
set Var1 Var2 Var3 Var4 ;
run;

Var1 Var2 Var3 Var4
38
0
0
40

I need an output as below,

Var1 38
Var2 0
var3 0
var4 40

Please let me know.
Thanks Message was edited by: Raveenat
3 REPLIES 3
ballardw
Super User
How did you summarize and combine the previous output? You may be creating extra work with that approach.
deleted_user
Not applicable
Hi

I created a count for each dataset by using this macros,

%macro cnt_inv (tbl=, vr=, table=);
PROC SQL;
create table &tbl. as
select count(*) as &vr. from &table.
quit;
%mend cnt_inv;

%cnt_inv (tbl=var1, vr=prior, table=test1);
%cnt_inv (tbl=var2, vr=worked, table=test2);
%cnt_inv (tbl=Var3, vr=new, table=test3)
%cnt_inv (tbl=var4, vr=crnt, table=test4);
Ksharp
Super User
Emmmm.
Maybe you will like dictionary table:


[pre]
proc sql ;
create table summary as
select memname label='Table Name',nobs label='Number of Observations'
from dictionary.tables
where libname='SASHELP' and memname in ('CLASS' 'SHOES');
quit;
[/pre]


Ksharp

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1075 views
  • 0 likes
  • 3 in conversation