Greetings all. I'm wanting to use SAS to call a VBScript file in a user's temp directory. After some googling, I found what I think should work, but I keep getting errors. In the below code, I am using %sysget(temp) to get the path, but then I want to append it with '\filename.vbs', but I am getting a 'not resolved error. Could anyone explain why? Thank you.
%let temp_path = %sysget(temp) ;
data _null_ ;
%put &temp_path ;
call symput('file_name',cat("'",&tpath,"\file_name.vbs","'")) ;
%put &file_name ;
run ; quit ;
Greg
Do you need CALL SYMPUT?
Move the %put statement OUT of the data step. The macro variable is not actually available until the datastep completes.
Generally you can't reference created macro variables in a datastep that creates them.
Thank you ballardw. I had the %put in there just so I could verify that the temp_file variable was being correctly assigned. It seems the real issue is when I try to use it in the symput routine. If I move the symput into it's own data step, that's where I get the issue...
* no problems here, temp_path assigned as expected ;
%let temp_path = %sysget(temp) ;
data _null_ ;
%put &temp_path ;
run ; quit ;
* now, when I try to use temp_path in a symput routine, I get error ;
data _null_ ;
call symput('file_name',cat(&temp_path,'\vbs_file.vbs')) ;
run ; quit ;
ERROR 388-185: Expecting an arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
What I would like to happen is to end up with a file_name variable eq 'C:\Users\username\AppData\Local\Temp\1\vbs_file.vbs', so that I can then use the file_name variable to write create, write to, then execute like below
data _null_ ;
x &file_name ;
run ; quit ;
Do you need CALL SYMPUT?
Thank you so much data_null_;. Once again, I was over complicating it. I put it in the symput because I need it for other stuff, and I figured that since it was already there, why not. Thank you.
Greg
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.