Programming the statistical procedures from SAS

N option?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 123
Accepted Solution

N option?

Hi!  I'm wondering if there is an option to include in the Proc Logistic preocedure that would output the number of observations used for each variable?

 

for example, if i am using gender as an independent variable, can I add something to the procedure that would output # males and # female observations in addition to all the statistical output?

 

Thanks!


Accepted Solutions
Solution
‎06-22-2016 10:25 PM
Respected Advisor
Posts: 4,746

Re: N option?

You will easily get some useful information (means, frequencies) in proc logistic with option SIMPLE.

 

proc logistic data=sashelp.heart simple;
class sex smoking_status;
model status = sex smoking_status weight;
run;

every table can be captured with ODS OUTPUT. 

PG

View solution in original post


All Replies
Super User
Posts: 18,542

Re: N option?

[ Edited ]

Not AFAIK, in general, I run a proc freq/means ahead of time to get a table of characteristics. 

 

Here's one way to get several proc freq results into a nice table at once:

https://gist.github.com/statgeek/e0903d269d4a71316a4e

 

/*This code is an example of how to generate a table with 
Variable Name, Variable Value, Frequency, Percent, Cumulative Freq and Cum Pct
No macro's are required
Use Proc Freq to generate the list, list variables in a table statement if only specific variables are desired
Use ODS Table to capture the output and then format the output into a printable table.
*/

*Run frequency for tables;
ods table onewayfreqs=temp;
proc freq data=sashelp.class;
	table sex age;
run;

*Format output;
data want;
length variable $32. variable_value $50.;
set temp;
Variable=scan(table, 2);

Variable_Value=strip(trim(vvaluex(variable)));

keep variable variable_value frequency percent cum:;
label variable='Variable' 
	variable_value='Variable Value';
run;

*Display;
proc print data=want(obs=20) label;
run;
Solution
‎06-22-2016 10:25 PM
Respected Advisor
Posts: 4,746

Re: N option?

You will easily get some useful information (means, frequencies) in proc logistic with option SIMPLE.

 

proc logistic data=sashelp.heart simple;
class sex smoking_status;
model status = sex smoking_status weight;
run;

every table can be captured with ODS OUTPUT. 

PG
Super User
Posts: 18,542

Re: N option?

Learn something new every day Smiley Wink

Respected Advisor
Posts: 4,746

Re: N option?

So do I Smiley Happy

PG
Respected Advisor
Posts: 2,655

Re: N option?

Mostly from you two Smiley Happy

 

Steve Denham

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 374 views
  • 6 likes
  • 4 in conversation