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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

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