Reputation: 53
I have a situation where am using sas x command to unzip a folder and select only .sas files from the same and the below code is working fine as there are no embedded spaces in the directory path..
x "cd &egp_location"; --> current directory --&egp_location resolves to folder path with no embedded spaces.
x "unzip &egp_name *.sas " ; --> with in the current directory &egp_name resolves a file name that need to be unzipped.
if there are embedded spaces the above lines of code is not working.
Please help.
Thanks
Upvotes: 0
Views: 1079
Reputation: 63424
You can do:
x "unzip ""&egp_name"" *.sas " ;
The double double quotes resolve to a single double quote character.
This assumes the unzip statement is otherwise valid - if you run
options mprint symbolgen;
you will get the full unzip statement in your log - copy/paste that to the console and see if it works. If not, debug that.
Upvotes: 2
Reputation: 5452
Try:
x cd %STR(%")&egp_location%STR(%");
x unzip %STR(%")&egp_name%STR(%") *.sas;
I'm not sure of the syntax of the unzip command, but the %STR bits will add quotes around the macro variables.
Also, double quotes are not required around the whole command when using the X statement in SAS.
Upvotes: 0