Hi Reader,
Here is some new understanding i am exploring, so could you please share the solution?
/*Input data*/
data abc ;
input dsc $ ;
cards;
a
a
c
b
b
b
b
;
run;
/*Output requirement*/
| b | c | a | total count |
| (n=4) | (n=1) | (n=2) | (n=7) |
data abc ;
input dsc $ ;
cards;
a
a
c
b
b
b
b
;
run;
proc sql;
create table temp as
select dsc, count(dsc) as count, (select count( dsc ) from abc) as total_count
from abc
group by dsc;
quit;
proc transpose data=temp out=want(drop=_:);
by total_count;
var count;
id dsc;
run;
I will prefer this kind of output-
proc sql;
create table temp as
select dsc, cat ("(n","=",count(dsc),")") as count, (select cat ("(n","=",count( dsc ),")") from abc) as total_count
from abc
group by dsc;
quit;
One basic approach:
proc tabulate data=abc;
class dsc;
table n,
dsc all='Total'
;
run;
If the output actually requires the ugly-to-me (n= ) that's another story.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.