Hello can someone assist me>
using the code below I am trying to do a file compare of 2 SAS programs to review the changes.
My issue is that the output file is not created. But when I run the FC command line from DOS it works.
How would I write this to make it work in BASE SAS.
data _null_;
do;
x fc "R:\Programs_files.sas T:\Programs_files.sas > R:\changes.txt";
end;
run;
To see if a command executed on the OS works, do this:
filename oscmd pipe 'fc /n R:\Programs_DRA2009\download\get_tanf_files.sas T:\Programs_DRA2009\download\get_tanf_files.sas 2>&1';
data _null_;
infile oscmd;
input;
put _infile_;
run;
This will catch all output (stdout and stderr) and write it to the SAS log.
First, note that X is a SAS statement, but not a DATA step statement. If you had a working X command, you could issue just the one line program:
x fc "R:\Programs_files.sas T:\Programs_files.sas > R:\changes.txt";
However, the X command requires that its argument be in quotes. In this case, you could simply add the quotes:
x 'fc "R:\Programs_files.sas T:\Programs_files.sas > R:\changes.txt"';
Another possibility here would be to switch from X to %SYSEXEC, which performs similar functions but does not requires quotes::
%sysexec fc "R:\Programs_files.sas T:\Programs_files.sas > R:\changes.txt";
I have tried both solutions but nether of them create a text output file.
I'm not too familiar with DOS commands, but this syntax strikes me as strange:
%sysexec fc "R:\Programs_files.sas T:\Programs_files.sas > R:\changes.txt";
Shouldn't it look more like this (or some other similar variation such as no quotes at all)?
%sysexec fc "R:\Programs_files.sas T:\Programs_files.sas" > "R:\changes.txt";
the extra set of quotes doesn't resolve and create an output text file.
Post the exact code you submitted from @Astounding solution.
And check if you have XCMD enabled.
Proc options option =xcmd; run;
If you don’t have xcmd enabled you can’t execute system commands.
these are the code I have used after the replies for help
Proc options option =xcmd; run;
data _null_;
do;
x 'fc /n"R:\Programs_DRA2009\download\get_tanf_files.sas T:\Programs_DRA2009\download\get_tanf_files.sas > R:\vdd_changes.txt"';
end;
run;
%sysexec fc "R:\Programs_DRA2009\download\get_tanf_files.sas T:\Programs_DRA2009\download\get_tanf_files.sas > R:\vdd_changes.tx";
when I run the type the code on a DOS command line it works
and I get a file that contains this information. I would like to run
fc R:\Programs_DRA2009\download\get_tanf_files.sas T:\Programs_DRA2009\download\get_tanf_files.sas > R:\vdd_changes.txt from a SAS session and use a macro for the filenames.
Comparing files R:\PROGRAMS_DRA2009\DOWNLOAD\get_tanf_files.sas and T:\PROGRAMS_DRA2009\DOWNLOAD\GET_TANF_FILES.SAS
***** R:\PROGRAMS_DRA2009\DOWNLOAD\get_tanf_files.sas
81: *
82: ***************************************************;
***** T:\PROGRAMS_DRA2009\DOWNLOAD\GET_TANF_FILES.SAS
81: *
82: * 01/12/2018 changed the filepath from \\dshsapoly80801\tanf_report
83: * to \\dshs\rda\tanf2018 in the libname statement and
84: * the renaming process. (M. Harris)
85: *
86: ***************************************************;
*****
I have also used this
%sysexec 'fc "R:\Programs_DRA2009\download\get_tanf_files.sas T:\Programs_DRA2009\download\get_tanf_files.sas > R:\vdd_changes.txt"';
and this
%sysexec 'fc "R:\Programs_DRA2009\download\get_tanf_files.sas T:\Programs_DRA2009\download\get_tanf_files.sas" > "R:\vdd_changes.txt"';
To see if a command executed on the OS works, do this:
filename oscmd pipe 'fc /n R:\Programs_DRA2009\download\get_tanf_files.sas T:\Programs_DRA2009\download\get_tanf_files.sas 2>&1';
data _null_;
infile oscmd;
input;
put _infile_;
run;
This will catch all output (stdout and stderr) and write it to the SAS log.
Output from PROC OPTIONS? I suspect XCMD is enabled to allow you to run these types of commands.
EG has this turned off by default.
Can you assist in telling me how to get EG to turn it on, or is there an option to turn it on in EG.
I use Base SAS
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!
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.