turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Creating a new database from aggregate data

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-17-2011 07:22 PM

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?

Accepted Solutions

Solution

07-17-2011
08:02 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-17-2011 08:02 PM

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;

All Replies

Solution

07-17-2011
08:02 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-17-2011 08:02 PM

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;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-18-2011 08:25 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-18-2011 01:47 AM

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

It will give you answer fastestly and correctly.

Ksharp