BookmarkSubscribeRSS Feed
astha8882000
Obsidian | Level 7

Hello,

 

I'm trying to run this piece of code, it does not produce any errors but does not give any output either, so I'm unable to understand what it is meant to do:

 

 

%let files=\\shared drive path\temp\abc\*.txt;

 

 

%macro disp (var);

     %sysrput &var = &&&var.;

%mend;

 

%disp(files);

 

I had a few questions, and would really appreciate if you could help me understand:

1. %let files command creates the folder abc in that location if it doesn't exist and also creates some txt files? Or is it just acting as a reference to those .txt files when they might get created in the future?

2. what purpose does the macro disp serve here? Is it to make the location of files global?

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Someone is showing off their ability to write extremely convoluted and extremely unnecessary and unbelievably difficult to understand code.

 

Nevertheless, use OPTIONS MPRINT; at the start of the code, run it again, as see what the SASLOG shows you.

--
Paige Miller
Tom
Super User Tom
Super User

It generates an error for me.

1    %let files=\\shared drive path\temp\abc\*.txt;
2    %macro disp (var);
3         %sysrput &var = &&&var.;
4    %mend;
5    %disp(files);
ERROR: %SYSRPUT statement is valid only when OPTION DMR is in effect.

It I replace the %SYSRPUT command with a normal %PUT command then it will write this to the log.

files = \\shared drive path\temp\abc\*.txt

Note that this program is not doing anything with any files or directories., just macro variables and their values.

 

The original program was designed to run in a remote submitted block of code and it would create a macro variable in the calling (local) SAS session with the same name and content as the macro variable that existed in the remote session.

If it ran correctly it would not produce any output or error messages.

ballardw
Super User

Is the DMR option set? The macro could be failing because the macro parser checks that option before attempting the %SYSRPUT statement.

 

You would also have to have an active connection to a remote host if I read the documentation correctly. Is one active?

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
  • 3 replies
  • 875 views
  • 0 likes
  • 4 in conversation