ods rtf filename in '/home/u50158717/all.sas';
all.sas ( executing file with ods statement)
data NuclearPilotPlant;
input A B C D conv tc $ random;
A=A;
...
filename out zip '/home/u50158717/all.zip';
ods rtf close;
How to do?
I am afraid I don't understand what you are trying to do.
Please provide additional details about:
Hi:
When you use ODS RTF, you should be creating an RTF file in the FILE= option. Instead, your code shows a .SAS file extension, and shows the use of a FILENAME statement used as an option, both of which would be incorrect. I'm not entirely sure what you're trying to do, however, assuming that you are using a SAS OnDemand for Academics server account and your home folder location path is /home/u50158717, then something like THIS should make an ODS RTF file for you:
data newclass;
set sashelp.class;
if age ge 14 then output;
run;
ods rtf file= '/home/u50158717/class_report.rtf';
proc print data=newclass;
title 'Eligible for Driver Training Class Now and within 2 years';
var name age sex;
run;
ods rtf close;
title;
The SASHELP library is loaded on the SAS OnDemand server, so you should be able to run this code. Note that the syntax for the ODS RTF statement uses a FILE= option and the result file and path are specified in the FILE= option. The DATA step that creates the file WORK.NEWCLASS is created OUTSIDE of the ODS RTF statements because 1) The DATA step is only creating a subset of rows from the SASHELP.CLASS file and so 2) does not produce any output that can be routed to the ODS RTF destination.
In your code snippet, your code has many syntax errors. It looks more like pseudo code or some kind of mash-up of several different program examples.
The purpose of the FILENAME statement is to point to an external file (such as a .CSV file or a .TXT file) for either INPUT or OUTPUT.
You use the constructs FILENAME IN and FILENAME OUT in your code snippet. First of all, FILENAME is a separate statement and does NOT belong as part of an ODS RTF statement. The correct option for ODS RTF is FILE=, not FILENAME.
Next, it looks like you're trying to read some data into a SAS format using code like this:
data NuclearPilotPlant;
input A B C D conv tc $ random;
A=A;
...
I'm not sure what the ... is for, but typically, I would expect to see more statements or a RUN; or a DATALINES or CARDS statement there. Not sure what your A=A; is needed for since, assuming your have a CARDS statement or a DATALINES statement followed by data, then your program should end with a RUN statement.
If you are trying to READ data from an external file you could use either a FILENAME statement or an INFILE statement. Let's say you have a file called "nukes.txt" in your /home/u50158717 SAS OnDemand account then something like this would work:
data NuclearPilotPlant;
infile '/home/u50158717/nukes.txt';
input A B C D conv tc $ random;
run;
OR
filename nukein '/home/u50158717/nukes.txt';
data NuclearPilotPlant;
infile nukein;
input A B C D conv tc $ random;
run;
Without any reference to a DLM option, the assumption for this code would be that all of your variables were separated by blanks and that the only character variable in the data file was the TC variable.
In either of the above programs, the unstructured data file, nukes.txt would be read into SAS using either the INFILE statement with the full path name or the FILENAME/INFILE statement and then the INPUT statement would parse the input lines and create 7 variables from each input line. Then each line or row would be output to the WORK.NuclearPilotPlant SAS data file.
If you want to see the contents of this data file in an RTF file, then you would use PROC PRINT, as the simplest way to show you a report so you could review the data that you had just read into SAS format.
We cover many of these basics of using SAS and PROC PRINT and ODS in our beginning Programming 1 class. This class is free to any independent learner.
If you are using a data file and sample code provided by your professor, then you could ask your professor teaching assistant for working code examples that will work on the SAS OnDemand server.
Cynthia
Thank you for the reply. I am inserting the print within halfnormal.sas. What is supposed to be in the input file? I just want an output file that I can edit? Error message says file does not exist. Well it does not.
Mary Marion
%macro halfnorm(dsn,varname,n,cancel=);
/* Creates a half-normal plot
ASSUMPTIONS
=============
Data is N(0,sigma**2)
INPUTS are the effects from a Yates analysis or an ANOVA
========================================================
dsn = Datafile, this is called by yatesGunstAnova and must stay dsn
varname = variable to be plotted
n = number of data points to be plotted
cancel = controls the creation of a fitted regression line through (0,0)
cancel=no draw
LVREF = line-type for vertical ref line, 2=dashed line
*/
data halfnormal; set &dsn;
abs_&varname=abs(&varname);
n=&n;
proc rank data=halfnormal out=ranks;
var abs_&varname;
ranks R;
run; quit; title;
data plotdata; set ranks;
abs_&varname=abs(&varname);
RSTAR = (R-.5)/n;
p= RSTAR/2 + .5;
v = probit(p);
run;
proc sort data=plotdata;
by descending abs_&varname; run;
ods rtf file= '/home/u50158717/plotdata.rtf';
title 'plotdata';
proc print data=plotdata; run; quit;
ods rtf close;
title 'v vs p'; run; quit;
PROC GPLOT DATA=plotdata;
plot v*p;
axis1 color=black label=(height=1.5 ) ;
axis2 color=black minor=none;
run; quit; title;
proc gplot data=plotdata;
PLOT v*abs_&varname /VREF=1 LVREF=2 REGEQN haxis=axis1 vaxis=axis2;
SYMBOL V=DOT I=RL0 COLOR=grey height=1.3 pointlabel=(height=10pt '#source' nodropcollisions) ;
TITLE "HALF-NORMAL PLOT";
TITLE2 'FITTED LINE THROUGH THE ORIGIN';
run; quit; title;
options nocenter;
goptions reset=all;
ods graphics on;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.