BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KMack
Calcite | Level 5

I am trying to make a new dataset based on output from another and I'm not sure even where to start.   Any direction is highly appreciated.

Here is a simplified version of what I'm trying to do.  I have a person-centered dataset, say with 100 people coming from a total of 10 communities.  I have a number of binary variables for each person (e.g. gender (m/f) and current smoker (y/n)).  I'm interested in creating community variables for each binary variable in these individual data, e.g. % male in each community and % smoker in each community.  Then I would like to use this community information in subsequent analyses (so now my n=10).

I'm seriously tempted to manually input the column % statistic from x*community frequency tables but I'm convinced there is a much better way, right?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

General PROC SUMMARY (proc means) is the easiest way to summarize the data.  For a binary (1/0) variables the mean is the same as the percent that have a 1.  So you could do something like this:

proc summary data=have  nway ;

  class community ;

  var sex smoker ;

  output out=want mean=male_percent smoker_percent ;

run;

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

General PROC SUMMARY (proc means) is the easiest way to summarize the data.  For a binary (1/0) variables the mean is the same as the percent that have a 1.  So you could do something like this:

proc summary data=have  nway ;

  class community ;

  var sex smoker ;

  output out=want mean=male_percent smoker_percent ;

run;

KMack
Calcite | Level 5

Thanks!  Proc summary generated exactly the output I was looking for.

Ksharp
Super User

You'd better to post some sample data and what output you need.

It will give you answer fastestly and correctly.

Ksharp

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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