BookmarkSubscribeRSS Feed
Daneul
Calcite | Level 5

Hello,

     In my stats class we were required to run all of our code up until "ods graphics on;" and then once the rtf was created, we were instructed to run the last two lines of code. When I open my Word rtf file, it's blank, but apparently I am supposed to be able to edit my graphs and tables. Any idea why this would be?

Thank you,

Dan

Here is the code:

ods rtf style= journal2 file="C:\Users\Dan\Desktop\216\hw4output.rtf" startpage=no bodytitle;

ods graphics on;

ods graphics off;

ods rtf close;

4 REPLIES 4
Reeza
Super User

Does the following work:

ods rtf style= journal2 file="C:\Users\Dan\Desktop\216\hw4output.rtf" startpage=no bodytitle;

ods graphics on;

proc reg data=sashelp.class;

model weight=age height;

run; quit;

ods graphics off;

ods rtf close;

Daneul
Calcite | Level 5

Sort of. I have output now, but it gave me some weird data and graphs. If my variables are sibs, age, sei, and yearsjob, how would the code change? I guess I should have specified my variables first.

Cynthia_sas
SAS Super FREQ

Hi:

  Reeza's suggestion was exactly the correct solution that illustrates how ODS works.

      

The "wrapper" code that your instructor gave you:

  

ods rtf style= journal2 file="C:\Users\Dan\Desktop\216\hw4output.rtf" startpage=no bodytitle;

ods graphics on;

.... your code goes here ....

ods graphics off;

ods rtf close;

    
is meant to be "sandwiched" around your code or your procedure -- whatever procedure or SAS process you are studying about in class. So, the wrapper code, submitted by itself, without any SAS code in the middle, would essentially create an "empty" or blank file.

 
Reeza gave you a working example with some SAS code that used SASHELP.CLASS. You would need to go back to your class instructions and find out what data and what procedure you would use in place of the procedure that Reeza gave you to test. The "weird" data and graphs were from PROC REG. With ODS GRAPHICS turned ON, you get the default regression graphs (fit plot, etc) that PROC REG draws, in addition to the tables that it builds. I expect that your professsor showed some other "weird" data and graphs in your class -- depending on what your whole task was -- I assume it was more than submitting empty wrapper code. I would also expect that your professor had some SAS procedures that you were supposed to run, perhaps on data that the professor prepared for you.

      

Since you are in a stats class, your instructor might not have planned to start with PROC REG. But, even if you tell us that your variables are SIBS, AGE, SEI, and YEARSJOB, it is hard for anyone to help you. Were you supposed to run an analysis of variance? Were you supposed to run Basic Measures of Location and Variability? Or, were you supposed to get Frequency counts or find the extreme observations?

Without knowing more about WHAT procedure you were supposed to put in your ODS "sandwich", there's no good way to help you. If you turn ODS GRAPHICS OFF before your initial ODS RTF statement, then your output will only contain the result tables/report. I assume your professor had you turn ODS GRAPHICS ON because you were meant to see/use the automatics graphs that ODS can create.

cynthia

Daneul
Calcite | Level 5

Oh I see what you're saying. Sorry, I'm a slow study when it comes to stats. :smileyconfused: There are comments about what commands would go between graphics on/off, but I'm just not sure what they are. We are trying to assess normality based on the plot and histogram output, as well as the statistics. Here is the full code:

/* STA 216 hw4 - This is a "seed" program to get you started.  You will

   add code below to complete the program. */

/* Run the below statement to gain access to permanent SAS data sets

   on the R drive, in the Anderson 216 folder. Note that it creates a

   library name called HW4.  */

libname hw4 'C:\Users\Dan\Desktop\216';

/* After submitting the above statement, we can make use of any

   permanent SAS data sets that are stored there, including GSS.

   The below code produces infromation about the data set.  Note that

   we refer to hw4.gss.  HW4 is the library name, and GSS is the data

   set name. */

proc contents data=hw4.gss;

title 'Information about the 2010 GSS sample of data';

run;

proc format;

value grp 1='Normal' 2='Right' 3='Left'

           4='Flat' 5='Peaked' 6='Uniform';

run;

/* The following data step reads in 100 observations randomly

   generated from a normal, right-skewed, left-skewed, flat,

   highly peaked, and uniform distribution. */

data hw4.gss;

infile 'C:\Users\Dan\Desktop\216\hw4.gss';

input hw4.gss group;

IDno = _N_;

label hw4.gss='Data Distribution' group='Distribution Type';

format group grp.;

run;

proc means data=hw4.gss n mean median stddev skew kurt maxdec=1 fw=5;

run;

proc univariate data=hw4.gss noprint;

histogram sibs / normal;

probplot sibs / normal (mu=8.402542 sigma=9.73912);

title2 'This should look normal!';

run;

proc univariate data=hw4.gss noprint;

histogram age / normal;

probplot age / normal (mu=8.402542 sigma=9.73912);

title2 'This should look normal!';

run;

proc univariate data=hw4.gss noprint;

histogram sei / normal;

probplot sei / normal (mu=8.402542 sigma=9.73912);

title2 'This should look normal!';

run;

proc univariate data=hw4.gss noprint;

histogram yearsjob / normal;

probplot yearsjob / normal (mu=8.402542 sigma=9.73912);

title2 'This should look normal!';

run;

/* Don't run the below ODS statements right away.  Wait until you have

   written the code needed to produce the output correctly.

   Once you have it figured out, you will use the below code to "start

   recording" an RTF document that can be edited in Word.  */

ods rtf style= journal2 file="C:\Users\Dan\Desktop\216\hw4output.rtf" startpage=no bodytitle;

ods graphics on;

/* Put your code here to create the output needed for this assignment */

/* After you have created the desired output, you "stop recording" by

   submitting the below statements. */

ods graphics off;

ods rtf close;

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
  • 4 replies
  • 3277 views
  • 6 likes
  • 3 in conversation