DATA Step, Macro, Functions and more

how to generate a complicated table without copying and pasting in excel

Reply
Super Contributor
Posts: 345

how to generate a complicated table without copying and pasting in excel

[ Edited ]

I need to generate a complicated table regarding race, age group, education and their scores. I need to do analysis first. So usually I would use sas to generate output and copy and paste in excel, and then present in a powerpoint or excel or word document.

I know someone can directly use SAS to do that, I would like to get advice from you if you can do that

 

if you need a sample data set, I have attached one. So previoulsy I need to generate five tables and then do copy and paste into one single table. If anyone can help to genearte the big table using SAS, please share.

 Thanks.

SAS Super FREQ
Posts: 8,868

Re: how to generate a complicated table without copying and pasting in excel

Hi: I'm not sure what you posted. It has an OBS column -- so is this your desired report? What code have you tried? You said that "usually I would use SAS to generate output and copy and paste in excel" -- so that means you have some kind of SAS code that you are starting with. Can you post that code and a sample of your data or use one of the SASHELP datasets to illustrate your question.

cynthia
Super User
Posts: 19,855

Re: how to generate a complicated table without copying and pasting in excel

Search LexJansen.com for sample code for either 'demographic' table or clinical reports. Your output looks similar though its hard to tell what you're actually trying to do. 

 

SAS is capable of creating very complex reports, but its not necessarily easy to do. 

 

It looks like just a big count table, so I have some code here that shows how to generate this in one table:

 

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

 

There's a worked example at the end that shows how to use the macro. 

 

 

 

Super Contributor
Posts: 345

Re: how to generate a complicated table without copying and pasting in excel

Thank you.  If I want to calculate realtive risk and 95%Ci instead of chisq, how and where I should replace, using your code as a template?

 

 

table &varcross/chisq out=temp1;

 

ods output OneWayChiSq=chisq;

 

run;

   
 

data temp2;

 

 

set chisq (where=(Statistic="Chi-Square") keep=prob statistic rename=(prob=chisq));

Super User
Posts: 19,855

Re: how to generate a complicated table without copying and pasting in excel

Yes, you can change the ODS output to capture the data required and to report that instead. 

 

If you're making changes, I suggest making one change, check if it works and then go forward step by step to change it to what you need.

Ask a Question
Discussion stats
  • 4 replies
  • 137 views
  • 0 likes
  • 3 in conversation