I am having some problem passing a string and parsing it in the SAS program.
I have a macro given below with signature
%macro findMatches (dir,pattern);
I invoke it as - With (sample values as below)
%let rootFolder = C:\DAG\SAS\Tests;
%let fileExt = .sas7bdat;
%findMatches(&rootFolder,&fileExt);
This works fine.
I am trying to run my SAS program through command line with the values for rootFolder and fileExt as command line arguments.
I want to send it as a string with both values separated with a character which will help me parse the 2 values in the program. I chose # as the separator character. So in the bat file I invoke the program as
"C:\Program Files\SAS\SASFoundation\9.2\sas.exe" -SYSPARM C:\DAG\SAS\Tests#.sas7bdat -SYSIN %program_path% -log %log_path% And I have something like below to parse and invoke the above mentioned macro
index = FIND(&SYSPARM,'#');
rootFolderTemp = SUBSTR(&SYSPARM,1,index-1);
fileExtTemp = SUBSTR(&SYSPARM,index+1);
%let rootFolder = rootFolderTemp;
%let fileExt = fileExtTemp;
%findMatches(&rootFolder,&fileExt);
I get the following error messages in the log file
-----------------------------------------------------------------------
123 index = FIND(&SYSPARM,'#');
NOTE: Line generated by the macro variable "SYSPARM".
123 C:\DAG\SAS\Tests#.sas7bdat
_
388
76
ERROR 388-185: Expecting an arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
124 rootFolderTemp = SUBSTR(&SYSPARM,1,index-1);
NOTE: Line generated by the macro variable "SYSPARM".
124 C:\DAG\SAS\Tests#.sas7bdat
_
388
76
ERROR 388-185: Expecting an arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
125 fileExtTemp = SUBSTR(&SYSPARM,index+1);
NOTE: Line generated by the macro variable "SYSPARM".
125 C:\DAG\SAS\Tests#.sas7bdat
_
388
76
ERROR 388-185: Expecting an arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
----------------------------------------------------------------
Any ideas how to resolve this?
Regards,
Neel