Help using Base SAS procedures

Output Out Using PROC SURVEYFREQ

Accepted Solution Solved
Reply
Regular Contributor
Posts: 199
Accepted Solution

Output Out Using PROC SURVEYFREQ

[ Edited ]

Can I ouput Weighted Frequency and other values from a PROC SURVEYFREQ table?

 

I am doing a 3 way comparison using PROC SURVEYFREQ - TABLES flag*year*age_cat*injury;

 

This produces a table w/ the frequency of injuries in each age category (i.e. age_cat)  by year. Ulitmately, I want an outputted dataset with the Weighted Freqency and Percent for injury for each age category and year. 

 

My ideal output would look like this:

 

year      age_cat    weighted frequency  percent

2002     0-2               125,000                      5.34

2002     3-10             127,000                      x.xx

2002     11-16           145,000                      x.xx

2002     17-21           115,000                      x.xx

2003     0-2               155,000                      7.34

2003     3-10             177,000                      x.xx

2003     11-16           115,000                      x.xx

2003     17-21           105,000                      x.xx

etc.

 

Thanks!


Accepted Solutions
Solution
‎11-22-2016 09:16 PM
Super User
Posts: 17,801

Re: Output Out Using PROC SURVEYFREQ


All Replies
Super User
Posts: 17,801

Re: Output Out Using PROC SURVEYFREQ

What exactly are you having trouble with then?

Regular Contributor
Posts: 199

Re: Output Out Using PROC SURVEYFREQ

[ Edited ]

I don't know the correct syntax. I've never used PROC SURVEYFREQ to output to a dataset before...

Super User
Posts: 17,801

Re: Output Out Using PROC SURVEYFREQ

You're switching to proc freq/surveyfreq, which one are you trying to run?

What have you tried? 

Regular Contributor
Posts: 199

Re: Output Out Using PROC SURVEYFREQ

[ Edited ]

I'm running PROC SURVEYFREQ. Sorry for the confusion. 

 

How do I identify, and output, the values I want? For example, how do I tell SAS I want the "Weighted Frequency" and the "Percent" in a new dataset named "want"? Are these listed as options in the TABLES statement? How do I specify that I want these values for the varialbe injury?

 

Something like this?

 

Tables flag*year*age_cat*injury / OUT=want, weightedfreq pct;

 

I have tried using ODS per these instructions, but I can only make it work for a oneway table. I don't know which keyword to use for what I DO want. I've tried "twoway", "fourway", "nway", each time the log states that output "twoway", for example, was not created.

ods output OneWay=WantTable;

 

Solution
‎11-22-2016 09:16 PM
Super User
Posts: 17,801

Re: Output Out Using PROC SURVEYFREQ

Find the correct table name using ODS TRACE.

 

http://blogs.sas.com/content/iml/2015/09/08/ods-table-names.html

Super User
Posts: 17,801

Re: Output Out Using PROC SURVEYFREQ

Actually, I didn't find the answer here, you did. 

If possible post what code you ended up using and mark that as the correct solution. 

Regular Contributor
Posts: 199

Re: Output Out Using PROC SURVEYFREQ

ODS OUTPUT CrossTabs=want;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 319 views
  • 4 likes
  • 2 in conversation