BookmarkSubscribeRSS Feed
rykwong
Quartz | Level 8

Dear SAS communities

I have a excel dataset that contains a 50 binary variables (e.g. history of diabetes: 1/0 etc), a variable "center" which contains the name of one of 10 hospitals

 

I just want to create a summary stats excel table where each of the 50 binary variables is listed as a line like this

variable                 N.       Nmiss.            frequent "0"      percentage "0"    frequent "0"      percentage "0"  

hx_diabetes.                                               xx.                       xx%.                    yy.                       yy%.      

hx_stroke                                                    xx.                       xx%.                    yy.                       yy%.      

 

then sort by "center" to output the same table restricting to each of the "center"

 

if you have a code that I can borrow, I would be grateful.  Thanks 

3 REPLIES 3
Reeza
Super User

Your last variables are duplicated so not sure what you're looking for there. Otherwise this can be standard output from PROC MEANS. 

PROC MEANS can do the N, NMISS. Frequency of a 1/0 variable is the SUM and Percentage is the Mean.

Note that you'll get a value for the Overall as well  as each facility with this code.

 

proc means data=have out=want stackods n nmiss sum mean;
class hospital;
var hx_: ; *use all hx variables;
ods output summary=MySummary;
run;
rykwong
Quartz | Level 8

thanks Reeza for your prompt response

 

this solves my problem, thanks again

 

rykwong
Quartz | Level 8

thanks Reeza for your prompt response

 

this solves my problem, thanks again

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 631 views
  • 0 likes
  • 2 in conversation