Hi All,
How to write sas output into word file?
Thank you very much for your help!
data have;
input group hypertension;
cards;
1 1
1 0
1 .
1 1
1 0
1 .
1 1
1 0
1 .
2 1
2 0
2 .
2 1
2 0
2 .
2 1
2 0
2 .
;
proc print;run;
| group1 | group2 | group3 | group4 | Total |
Smoking Status |
|
|
|
|
|
Never | 270/603(45%) | 231/457(51%) | 235/603(39%) | 202/457(44%) | 724/2120(34%) |
Past | 275/603(45%) | 201/457(44%) | 309/603(51%) | 225/457(49%) | 1018/2120(48%) |
Current | 47/603(8%) | 19/457(4%) | 35/603(6%) | 17/457(4%) | 118/2120(6%) |
Missing | 11/603(2%) | 6/457(1%) | 24/603(4%) | 13/457(3%) | 268/2120(12%) |
|
|
|
|
|
|
Physical Activity |
|
|
|
|
|
Yes | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) |
No | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) |
Missing | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) |
|
|
|
|
|
|
Hypertension |
|
|
|
|
|
Yes | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) |
No | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) |
Missing | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) |
what are you wanting to put into the text file?
How did you define the rows. Can you provide more detail?
Hi VDD,
Thank you for your quick reply! when I run the code below I would like the outcome of proc freq going to the word file directly, so I don't have to type in the numbers.
proc freq data=have;
tables hypertension/missing;
where group=1;
run;
group=1 group=2
Hypertension |
|
|
|
|
|
Yes | 3/9 (33%) | 3/9 (33%) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) |
No | 3/9 (33%) | 3/9 (33%) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) |
Missing | 3/9 (33%) | 3/9 (33%) | xx/xx (xx) | xx/xx (xx) | xx/xx (xx) |
|
|
|
|
|
|
This worked for me, but i don't know if this is what you want
ods rtf file='C:\Users\nsriniv2\Documents\Doc1';
proc freq data=sashelp.class;
tables sex/missing;
run;
ods rtf close;
Hi: usually with ODS RTF, you use a file extension of RTF:
ods rtf FILE='c:\myreports\doc1.rtf' style=journal;
When you are using ODS RTF, you are NOT creating a .doc or .docx file. You are creating an RTF (Rich Text Format) file that many word processors know how to open and render.
Cynthia
@Cynthia_sas Oh yes indeed. Thank you!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.