1 year ago

#384977

test-img

barnsm2

How to export editor code in SAS to word (rtf) file with tables

I have this code in SAS for an assignment. I am learning SAS and have completed all of the items already coded for and successfully have reviewed the output in the log and the results tab of SAS. I have the code included below:

ods listing close;
ods rtf file="C:\Users\barnedsm\Desktop\SAS
\Homework 8 hm.rtf" style=htmlblue;
1. read in the data into SAS to get a SAS data set trees using the proc import statement. (5 
points)
proc import 
datafile="C:\Users\barnedsm\Desktop\SAS\Trees.csv" 
dbms=csv 
out=trees;
run;

2. print the first 5 observations of the data set using the proc print statement. (5 points)
proc print data=trees (obs=5);
run;

3. get the summary for the three variables (Girth, Height and Volume) of the data using 
the proc means statement. (5 points)
proc means data=trees;
var Girth Height Volume;
run;

4. sort the data by Girth, Height and Volume variables. (1.5 bonus points)

Girth
proc sort data=trees out=trees; 
by Girth;
proc print data=trees (obs=5);
run;

Height
proc sort data=trees out=trees; 
by Height;
proc print data=trees (obs=5);
run;

Volume
proc sort data=trees out=trees; 
by Volume;
proc print data=trees (obs=5);
run;

Three Variables
proc sort data=trees out=trees; 
by Girth Height Volume;
proc print data=trees (obs=5);
run;

libname mylibr "C:\Users\barnedsm\Desktop\SAS";
data mylibr.trees_permanent; 
set trees;
run;

5. read in the data into SAS to get a SAS data set ToothGrowth using the proc import 
statement. (5 points)
proc import
datafile="C:\Users\barnedsm\Desktop\SAS\ToothGrowth.csv" 
dbms=csv
out=tooth;
proc print data=tooth (obs=5);
run;

6. create two SAS data sets ToothGrowth_OJ and ToothGrowth_VC for the animals with the 
delivery method orange juice and ascorbic acid, respectively. (5 points)
data ToothGrowth_OJ; 
set tooth;
where (supp="OJ");
proc print data=ToothGrowth_OJ (obs=5);
run;

data ToothGrowth_VC; 
set tooth;
where (supp="VC");
proc print data=ToothGrowth_VC (obs=5);
run;

7. save the two SAS data sets in a permanent folder on your computer. (5 points)
libname mylibr "C:\Users\barnedsm\Desktop\SAS";
data mylibr.ToothGrowth_OJ_permanent; 
set ToothGrowth_OJ;
run;

libname mylibr "C:\Users\barnedsm\Desktop\SAS";
data mylibr.ToothGrowth_VC_permanent; 
set ToothGrowth_VC;
run;

ods rtf close;
ods listing;

This works just fine, giving me an output with tables, but I want the SAS code from the editor included, which is the code above. How would I accomplish this? This is my first time using SAS, so I am very new. enter image description here

The picture is one of the charts that was outputted, so the code works. But I'd like the SAS code included in the exported word (rtf) file. I have tried also removing the ads listing code, but it made no difference. Can anyone point out why my code is not included or direct me on how to do so. I mostly use R and R Studio, so this exporting format is new to me.

sas

0 Answers

Your Answer

Accepted video resources