BookmarkSubscribeRSS Feed
Katy
Calcite | Level 5

Hi there

I'm struggling with the following macro. I'm quite new to the macro language and picking it up as I go along, so it may well be something pretty fundamental that I've misunderstood.

%let ref = %sysfunc(open(libname.filename));

%macro name;

%do i = 5 %to &errstop;

     %let variname = %sysfunc(varname(&ref,&i));

...some more code...

%end;

%mend;

The log tells me that &errstop resolves to 25 and that &ref resolves to 1, but I then get the following error:

WARNING: Argument 1 to function VARNAME refrenced by the %SYSFUNC or %QSYSFUNC macro function is missing or out of range.

Can anyone help me to understand what that means, please?

Thanks

Katy


4 REPLIES 4
art297
Opal | Level 21

What is &errstop.?  When I ran your code, as shown below, and ran perfectly:

%let ref = %sysfunc(open(sashelp.class));

%macro name;

%do i = 1 %to 5;

     %let variname = %sysfunc(varname(&ref,&i));

     %put &variname.;

%end;

%mend;

%name

Katy
Calcite | Level 5

Interesting. It's a macro variable defined earlier on in the code but it hadn't occured to me from the error message that that's where the problem might be. I'll look at that bit more closey - thanks for your help.

Katy
Calcite | Level 5

Nope, I'm still getting the same error even if I replace the start and stop values for the do loop as you have done. The only other difference is the actual file I'm using - could there be something wrong with that?

Katy
Calcite | Level 5

OK, somewhat embarrassingly, I've found the error in some of the code I didn't reproduce. I'd accidentally got a close statement between the open statement and the macro, and now I've moved that it works fine. Thanks very much for your help, though - you got me looking wider to find the problem!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3138 views
  • 3 likes
  • 2 in conversation