DATA Step, Macro, Functions and more

What is Method?

Reply
Occasional Contributor
Posts: 10

What is Method?

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

 

Super User
Posts: 10,476

Re: What is Method?

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.

SAS Super FREQ
Posts: 8,740

Re: What is Method?

Hi:
RUNMODEL: looks like the beginning of a named section or label in a program you would typically also see a LINK statement that would link to this section, as shown here:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000201972.htm

see the program and the example of the CALCU section called in a LINK statement.

The rest of the code in that section almost looks like the rest of a LENGTH statement that declares the lengths for a group of variables.

Anytime you see & or % references in a program, those are indications that the program is using macro variable references (&macvar) or macro functions (%function) or macro programs (%macpgm). So in that context, someplace in your program you would either see a %LET statement that sets a value for FAFILE or you will see a CALL SYMPUT that might set a value for FAFILE. It is hard to say more without seeing more code.

As @ballardw pointed out, in order for you to run the program successfully, you have to know how the macro variable value gets set and the macro variable has to have a value before the program will run successfully.

cynthia
Occasional Contributor
Posts: 10

Re: What is Method?

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... 

Occasional Contributor
Posts: 10

Re: What is Method?

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 ;

Super User
Posts: 3,101

Re: What is Method?

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?

Occasional Contributor
Posts: 10

Re: What is Method?

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.

Super User
Posts: 10,476

Re: What is Method?

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.

Super User
Posts: 3,101

Re: What is Method?

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:

 

http://support.sas.com/documentation/cdl/en/sclref/67564/HTML/default/viewer.htm#p1dm2u2fhop2xjn113d...

 

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?  

Ask a Question
Discussion stats
  • 8 replies
  • 233 views
  • 8 likes
  • 4 in conversation