I'm running a bunch of programs with pre-written code that includes infile statements with URLs such as the code below.
infile '.\pbp\pbp_b1a_inpat_hosp.txt' delimiter = '09'x
dsd lrecl = 30000 firstobs=2 missover;
Of course, I can manually change the "." to a directory for each program, but I'm wondering if there is a way "point" the period to a directory.
How many programs do you expect to modify?
With that first "directory" have to change again? Note, Paths for files really should start at a drive, or in the case of a url a server, so there is no ambiguity as to what location is meant.
Would all the other elements of the path stay the same would they need to change as well? You ask about . but what about the \php\? Will the new location have that folder? Other folders appearing in other paths?
Are the programs all in the same location? A few locations? Scattered nearly randomly across multiple physical locations?
There are potential time issues with some solutions to the "how many" question. If it takes a few hours to debug and verify an the values it is likely not worth the effort for just a few files but may be if there are hundreds involved.
If the paths may have to change frequently then a likely approach would be to replace the . with a macro variable that could be set before running the programs. However you would also have to make the path inside double quotes for the macro variable to resolve.
If an approach has to search just to find the files that is another set of things to be resolved.
If the scrip locations are nice the source text is no worse than you show then perhaps a SED script would be sufficient, no SAS involved needed at all for text replacement.
How many programs do you expect to modify?
With that first "directory" have to change again? Note, Paths for files really should start at a drive, or in the case of a url a server, so there is no ambiguity as to what location is meant.
Would all the other elements of the path stay the same would they need to change as well? You ask about . but what about the \php\? Will the new location have that folder? Other folders appearing in other paths?
Are the programs all in the same location? A few locations? Scattered nearly randomly across multiple physical locations?
There are potential time issues with some solutions to the "how many" question. If it takes a few hours to debug and verify an the values it is likely not worth the effort for just a few files but may be if there are hundreds involved.
If the paths may have to change frequently then a likely approach would be to replace the . with a macro variable that could be set before running the programs. However you would also have to make the path inside double quotes for the macro variable to resolve.
If an approach has to search just to find the files that is another set of things to be resolved.
If the scrip locations are nice the source text is no worse than you show then perhaps a SED script would be sufficient, no SAS involved needed at all for text replacement.
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: