BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have data which contains list of people with their sex, age and the country they moved from and the state they moved to:

NAME AGE SEX FROM TO
John Smith 25 M Canada Maryland
Mary Fernandez 4 F Spain Illinois
etc.

I need 2 datasets (one for males and one for females) for each US state:

In these datasets there should be numbers of people moving to the particular state totalled per foreign country by sex and age.

For example I should be able to look at the Maryland (male) table and see that 12 men aged 36 moved there from Canada for example.

Anyone have any idea how I can do this or even get started? I am not a programmer and I am stuck. Thanks!

mu Message was edited by: michaelaunsworth
4 REPLIES 4
Doc_Duke
Rhodochrosite | Level 12
Use PROC FREQ and output the table to a dataset, then split the dataset (or run FREQ twice, once for men and once for women; men shown below):

PROC FREQ DATA=mydata(WHERE=(sex='M'));
TABLES to*from*age/out=males;
RUN;
deleted_user
Not applicable
Thanks Doc, the HTML output is exactly what I was looking for

Other than cutting and pasting, is there any way of getting the tables in the HTML output into either a SAS dataset or an excel dataset?
ssas
Calcite | Level 5
Hi,
in my view first prepare the dataset first ( sdata).
later

data maledataset femaledataset;
set sdata;
if gender eq "F" then output femaledataset;
else if gender eq "M" then output maledataset;
run;

/* it would create one for male and another for female.*/

hope it may help you
Doc_Duke
Rhodochrosite | Level 12
One approach to getting the output into a dataset or export is to use ODS. You can create/output/manipulate pretty much anything you can print from a procedure. You'll need to read a good bit of documentation or BBUs to become proficient, but the results can be quite useful.

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
  • 4 replies
  • 567 views
  • 0 likes
  • 3 in conversation