BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gsnidow
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

Do you need CALL SYMPUT?

%let temp_path = %sysget(temp);
%let file_name = &temp_path\vbs_file.vbs;

View solution in original post

4 REPLIES 4
ballardw
Super User

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.

gsnidow
Obsidian | Level 7

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 ;

data_null__
Jade | Level 19

Do you need CALL SYMPUT?

%let temp_path = %sysget(temp);
%let file_name = &temp_path\vbs_file.vbs;
gsnidow
Obsidian | Level 7

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1053 views
  • 0 likes
  • 3 in conversation