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

Greetings,
I am using an unnamed pipe access method and filevar option to read multiple files from a directory. The directory letter in my macro variable (P) is not the directory the error message (C hard-drive) references. Why isn't the filevar option pointing to the indicated directory? I can run a directory list using the filename statement, so the pipe is working correctly.
Thanks in advance for your review.

ERROR MESSAGE - " Physical file does not exist, C:\Documents and Settings\....txt.

CODE

%let my_dir = P:\PCP\Data\from_JMG;
filename indata pipe "dir ""%unquote(&my_dir.*.txt)"" /b";
data JMG;
lenght fil2read $256;

infile indata ;
input f2r $60.;
fil2read='&my_dir'||f2r;
infile __test filevar=fil2read truncover end=done;
do while (not done);
input Member__ $1.
Alternate_Member__ $7. Subscr__ $50. Medicare_Id $14. Medicaid_Id $10.
Mem_Last_Name $90. Mem_First_Name $90. Mem_Initial $7. Mem_DOB mmddyy10. PCP_Sys_ID best32.
Do_Not_Verify $1. PCP_Att__Method best32. Verify_Date yymmdd10. Prov_NPI best32. Prov_Last_Name $16.
Prov_First_Name $10. Prov_Initial $1. Practice_NPI $10. Practice_Name $52. Comments $74.
Plan_ID best32. Plan_Name $20. Finacial_Class $17. ;
output;
end;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Did the path work correctly before attempting the macro variable subsitution? I think that the way you construct your macro variable you need a "\" at the end.

%let my_dir = P:\PCP\Data\from_JMG\; If you are trying to get a listing of the text files in directory from_JMG.

Otherwise your are looking for files P:\PCP\Data\from_JMG*.Txt  which would be files starting with from_JMG in Folder Data.

Also this:

fil2read='&my_dir'||f2r;

may not be resolving the way you want. If F2R values are less than 60 characters the contcatenated value of Fil2Read will have possible many spaces between the UNRESOLVED value &My_DIR and the FR2 text. This would result in an invalid variable name if that's what you are attempting.

As a minimum Fil2Read="&my_dir"||Strip(F2r); is probably needed. Macro variable must be between double quotes to resolve.

View solution in original post

2 REPLIES 2
ballardw
Super User

Did the path work correctly before attempting the macro variable subsitution? I think that the way you construct your macro variable you need a "\" at the end.

%let my_dir = P:\PCP\Data\from_JMG\; If you are trying to get a listing of the text files in directory from_JMG.

Otherwise your are looking for files P:\PCP\Data\from_JMG*.Txt  which would be files starting with from_JMG in Folder Data.

Also this:

fil2read='&my_dir'||f2r;

may not be resolving the way you want. If F2R values are less than 60 characters the contcatenated value of Fil2Read will have possible many spaces between the UNRESOLVED value &My_DIR and the FR2 text. This would result in an invalid variable name if that's what you are attempting.

As a minimum Fil2Read="&my_dir"||Strip(F2r); is probably needed. Macro variable must be between double quotes to resolve.

persephone3
Calcite | Level 5

I'm embarrased to say but it was simply a change from single to double quotes that was needed.  Thanks much for prompt response and resolution!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2863 views
  • 0 likes
  • 2 in conversation