BookmarkSubscribeRSS Feed
OGA13
Obsidian | Level 7

I'm trying to fetch files and put them in a single sas file using X Command.

The error is given because in the file path there is a space.

How can I fix it?

data helper;
    length Module $50 Function $100;
    set helper;
    Module = "HELPER";
	Path = "V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\"||strip(Module)|| "\" || strip(Function) || ".sas";
run;

proc print data=helper;
run;


%macro fetch_files(module=, output=);
	data _null_;
	    set &module end=last;
	    /* Construct the copy command */
	    if _n_ = 1 then call execute('X "copy ');

	    call execute('"', Path, '" + ');

	    /* Finalize the command when the last file is processed */
	    if last then call execute('"&output"');
	run;
%mend ; 


 %fetch_files(module=helper, output=helper.sas);
5 REPLIES 5
Patrick
Opal | Level 21

Then wrap the path or at least the portion with the blank in it into double quotes.

data helper;
  length Module $50 Function $100;
  set helper;
  Module = "HELPER";
/*Path =          "V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\"||strip(Module)|| "\" || strip(Function) || ".sas";      */
  Path = cats('"',"V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\",       Module ,  "\",         Function,    ".sas",'"');
run;

 

OGA13
Obsidian | Level 7

It seems that your suggestion fix the issue. But still, when I run the macro I don't see the desired file generated.
I'm sharing the LOG.

MLOGIC(FETCH_FILES):  Beginning execution.
MLOGIC(FETCH_FILES):  Parameter MODULE has value helper
MLOGIC(FETCH_FILES):  Parameter OUTPUT has value helper.sas
MPRINT(FETCH_FILES):   data _null_;
MPRINT(FETCH_FILES):   set helper end=last;
MPRINT(FETCH_FILES):   if _n_ = 1 then call execute('X "copy ');
MPRINT(FETCH_FILES):   call execute(cats('"', Path, '" + '));
MPRINT(FETCH_FILES):   if last then call execute(cats('"', Path, '"','" &output"'));
MPRINT(FETCH_FILES):   run;

NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.
NOTE: There were 11 observations read from the data set WORK.HELPER.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: Line generated by the CALL EXECUTE routine.
2     + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\APPEND_GMAP.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
3     + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\APPLY_VAR_TYPE.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
4     + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\ASSIGN_RECORDID.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
5     + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\CREATE_HORIZON_TEMPLATE.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
6     + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\LOG_BACKUP.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
7     + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\LST_BACKUP.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
8     + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\MASTER_FORMOID.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
9     + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\POST_DOMAIN.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
10    + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\REFRESH_FROM_PILOT.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
11    + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\RENAME_SPEC.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
12    + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\REPORT_LOGMSG.sas"" +
        --
        49
NOTE: Line generated by the CALL EXECUTE routine.
13    + ""V:\Projects\BOE\_BI\Consulting\05. System\Macros\Horizon\HELPER\REPORT_LOGMSG.sas""" helper.sas"
        --
        49
MLOGIC(FETCH_FILES):  Ending execution.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space between a quoted string
             and the succeeding identifier is recommended.

PaigeMiller
Diamond | Level 26

@OGA13 wrote:

I'm trying to fetch files and put them in a single sas file using X Command.

The error is given because in the file path there is a space.

How can I fix it?


Show us the log.


Is the error because of the space after 05.    ?? Or is the error somewhere else?

 

If you look in data set PATH, do you see an unnecessary space in variable PATH? If so, where is it?

--
Paige Miller
OGA13
Obsidian | Level 7
Yes, the error is gaven by the space after "05.". However, even with the correct path I still don't get any generated SAS file.
yabwon
Onyx | Level 15

1) do not use X for the job.

2) if you have multiple files you want to copy to a single .sas file and all of then are in one directory you can do it like this:

/* create some text files */
filename f "R:\test\";

data _null_;
file f(a.sas);
put "data _null_; run;";

file f(b.sas);
put "proc print data=sashelp.class; run;";

file f(c.sas);
put '%macro test(n); %do i = 1 to &n.; %put &=i.; %end; %mend;';

file f(d.sas);
put '%test(42)';
put "data _null_; run;";
run;
/* get them all into one file */
filename in_list "R:\test\*.sas";
filename out "R:\out\allInOne.sas";

data _null_;
  infile in_list;
    file out;
  input;
    put _infile_;
run;

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 5 replies
  • 363 views
  • 2 likes
  • 4 in conversation