Hello,
I'm pretty new to SAS and have a file to understand the whole procedure. I was trying to run the code to analyze the results but it starts with this:
RUNMODEL:
METHOD PRFILE $ 20 RAFILE $ 20 RRFILE $ 20 FAFILE $ 20
FPFILE $ 20 DEFILE $ 20 REFILE $ 20 CAFILE $ 20
ALFILE $ 20 COMMENT $ 60 PCTRATE 6
NUMWHSES MAXRUN 4;
Also in some places is referred to these inputs like this:
SET &FAFILE
does anybody know what does this command do and why I cannot run that?
Thank you in advance,
Mina
You may need to show more code as you showing parts of code. Some bits are common to more than one procedure but often have their own dependencies. You should have a Log that shows the code you submitted and would have error or possibly warning messages at to why something does not work. You can copy and paste the relavent log results into the entry box opened from the menu {i} above.
The Set statment usually is used in a data step and refers to one or more data sets to incorporate into the current step for processing. The &FAFILE refers to a macro variable that should contain the name of one or more existing data sets and possibly data set options.
If the macro varaible is blank you would get a message such as this:
188 data _null_; 189 set &fafile; - 22 200 WARNING: Apparent symbolic reference FAFILE not resolved. ERROR: File USER.FAFILE.DATA does not exist. ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, END, INDSNAME, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_. ERROR 200-322: The symbol is not recognized and will be ignored. 190 run;
If the FAFILE references a libbrary you may get a message about the library name is not assigned. If the data set referenced doesn't exist you would get a file does not exist error.
If you run this snippet of code it should show the assigned text of the macro variable:
%put FAFILE resolves to: &FAFILE;
The value will appear in the log.
Thank you so much. Here is the problem, as you can see in the whole very beginning part of the program that I posted later, these kinds of macro variables are not introduced to the program before referring them...
This is exactly how the file begins and I'm so clueless...
LENGTH MAXTIME 8 DIR $8;
RUNMODEL:
METHOD PRFILE $ 20 RAFILE $ 20 RRFILE $ 20 FAFILE $ 20
FPFILE $ 20 DEFILE $ 20 REFILE $ 20 CAFILE $ 20
ALFILE $ 20 COMMENT $ 60 PCTRATE 6
NUMWHSES MAXRUN 4;
ENVLST = ENVLIST('L');
DATA LOGBASE LOGNEW ;
SET &DIR.LOG_RUNS ;
OUTPUT LOGBASE ;
IF _N_ = 1 THEN OUTPUT LOGNEW ;
RUN ;
The output in the log is as bellow. Not surprisingly, it shows error for everything!
1 LENGTH MAXTIME 8 DIR $8;
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
2
3 RUNMODEL:
4
5 METHOD PRFILE $ 20 RAFILE $ 20 RRFILE $ 20 FAFILE $ 20
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
6 FPFILE $ 20 DEFILE $ 20 REFILE $ 20 CAFILE $ 20
7 ALFILE $ 20 COMMENT $ 60 PCTRATE 6
8 NUMWHSES MAXRUN 4;
9
10 ENVLST = ENVLIST('L');
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
11 CMDLST = GETNITEML(ENVLST,'_CMDLIST_');
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
12 DIR = GETNITEMC(CMDLST,'LIBNAME');
---
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
13
14 MAXTIME = MAXRUN * 60;
-------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
15
16 SUBMIT CONTINUE ;
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
CMDLST = GETNITEML(ENVLST,'_CMDLIST_');
DIR = GETNITEMC(CMDLST,'LIBNAME');
MAXTIME = MAXRUN * 60;
SUBMIT CONTINUE ;
This looks like SCL (Screen Control Language) to me. Where are you trying to run this? If you are trying to run this like a "normal" SAS program I'm not surprised it is failing. Where did you get the code for this?
So where can I run the code? I need to understand the whole procedure and then make the modifications in some parts. That is why I am trying to run the whole code to analyze the current output as the first step.
SAS has the ability for one program file to call the contents of another file. It may be that what you are seeing is one such file that is referenced by:
%include "<path>\name of your codefile.sas";
where path would be a system path like C:\folder\subfolder pointing to the location of the program file and "name of your codefile.sas" would be the name of the file you are attempting to figure out.
It is not real good practice to have parts of a file not starting with a proper boundary but it is possible that is what some in the past did.
Unfortunately since the path could refer any valid location from the standpoint of the calling program that calling program need not be stored with the subordinate. You may want to start opening any other program files you find and search for %include statements and see if something pops up that looks somewhat like the name of the file.
For future reference if you do any code like this it would be a very good idea to put a comment at the top to document what is going on. Possibly something like:
/* This program file is conditionally %included by a call from C:\path\otherfolder\ProcessControl.sas when
<describe condition> occurs in the main program */
Better is to include 1) who wrote it and 2) when and 3) more about the overall process such as what inherited macro variables represent.
An SCL (actually SAS Component Language) program is normally run from a SAS/AF Application. Here is a link explaining just one of the statements in your program ENVLIST:
Again, how are you running this program? SAS/AF applications can only be run within SAS Display Manager on a PC with a full SAS installation.
What is the context of this program? Has it been provided to you as part of a SAS/AF application or some other way?
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.