BookmarkSubscribeRSS Feed
Woop122
Calcite | Level 5

Hi,

 

If I'm doing a chisq test or proc logistic, how do I get the results in a data table that can be exported into excel? For example, for the code below, I would like to have the odds ratio, p-value, and confidence intervals in a table for excel export. Same question for proc logistic. 

 

DATA QUESTION;
INPUT GENDER $ RESPONSE $ COUNT;
DATALINES;
WOMEN YES 28
WOMEN NO 13
MEN YES 19
MEN NO 26

;

PROC FREQ DATA=QUESTION ORDER =DATA;
WEIGHT COUNT;
TABLES GENDER*RESPONSE / CHISQ RELRISK;
RUN;

 

proc logistic data = question desc;
class gender;
model response = gender;
run;

5 REPLIES 5
Reeza
Super User

1. You can direct the output to Excel 'automatically' (assumes SAS 9.4 TS1M3+)

 

ods excel file='mydata.xlsx' style=meadow;

<insert your SAS code here>;


ods excel close;

2. The second option is more manual unfortunately but if you're looking for production ready tables this will get you closer.

You would capture the tables you want and then proc print or proc report this out to an Excel file.

 

http://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html

ChrisNZ
Tourmaline | Level 20

Add this to you code and look in the log. You'l lsee all the outputs you can redirect.

 


ods trace on;

proc logistic data = question desc;
class gender;
model response = gender;
run;

ods trace off;

From there you can use ODS OUTPUT statements to capture the bits you want.

 

http://support.sas.com/documentation/cdl/en/odsug/69832/HTML/default/viewer.htm#p1fpt3uuow90o3n155hs...

http://support.sas.com/documentation/cdl/en/odsug/69832/HTML/default/viewer.htm#p0oxrbinw6fjuwn1x23q...

Woop122
Calcite | Level 5

Is there a way to do this without using the ODS excel? I want to export to an already existing excel file and create new tabs, rather than create a whole new file each time. 

 

thank you. 

Reeza
Super User

@Woop122 wrote:

Is there a way to do this without using the ODS excel? I want to export to an already existing excel file and create new tabs, rather than create a whole new file each time. 

 

thank you. 


Not easily but it could be done. You'd have to capture the tables of interest using ODS anyways and then export them manually using PROC EXPORT.

 

Here's a link on how that can be done:

http://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html

Reeza
Super User
I guess...the answer is the same as above 🙂

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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