BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Cornelis
Fluorite | Level 6

Dear SAS users,

 

The macro variable "thisyear" cannot be resolved in the Filename statement.

 

%let thisyear = 2024;

filename DIRLIST2 pipe 'dir "\\msnlgoudcp3102\nlgouddata\GLC\LZ-analyses\to be printed\&thisyear\vetzuur" /s';

data dirlist_LZ;
     length buffer $256 ;
	 format file $200. GLC_where $3.;
     infile dirlist2 length=reclen ;
     input buffer $varying256. reclen;
run;
Could you please offer a solution how to solve?
 
Thank you,
 
Cornelis
 
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
filename DIRLIST2 pipe %sysfunc(quote(dir "\\msnlgoudcp3102\nlgouddata\GLC\LZ-analyses\to be printed\&thisyear\vetzuur" /s));

View solution in original post

4 REPLIES 4
Ksharp
Super User
filename DIRLIST2 pipe %sysfunc(quote(dir "\\msnlgoudcp3102\nlgouddata\GLC\LZ-analyses\to be printed\&thisyear\vetzuur" /s));
Cornelis
Fluorite | Level 6
Thank you for your contribution. it works!
FreelanceReinh
Jade | Level 19

Hello @Cornelis,

 

The outer single quotes prevent the resolution of the macro variable reference. Use double quotes instead and duplicate the existing inner double quotes:

filename DIRLIST2 pipe "dir ""\\msnlgoudcp3102\nlgouddata\GLC\LZ-analyses\to be printed\&thisyear\vetzuur"" /s";

 

Cornelis
Fluorite | Level 6
Indeed, this option works also. Great to see that there are different option and of course, your prompt action.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 540 views
  • 4 likes
  • 3 in conversation