Does anyone have code that can pull in a bunch of SAS programs from location A and output them as .txt files in location B? Would save hours of work. Thanks!
Open a cmd window, navigate to path_a with cd, and do
copy *.sas c:\path_b\*.txt
Command line:
copy <path>/*.sas <path>
I mean SAS program files are just plain text programs. I don't see how this can take "hours of work"?
I have hundreds of programs - and the only way I knew how to do it was to open each one and do SAVE AS.
I am not really following the code you provided - if you could provide example paths that'd be helpful...thanks!
It's just the basic copy command of Windows. Use the commandline for it.
If your programs are stored on a non-Windows server, and you want to move/copy them there, you need to tell us more about your setup.
Why do you want to change the extension to .txt?
It's required by the FDA
SAS program files are text files.
Are you asking how to copy files?
In Windows the command is COPY and in Unix it is cp.
I am trying to do something like this - but the below code won't work:
libname rna "C:\data";
%macro export_data (file=);
proc export data=rna.&file.
outfile="C:\data.&file..txt"
dbms= tab replace;
run;
%mend export_data;
%export_data (file= t-14-1-1a-ds);
So you are not converting programs, but datasets!
Your code won't work because t-14-1-1a-ds is not a valid SAS dataset name. SAS names can only contain letters (of the 26 character alphabet), digits and underlines, and must not start with a digit.
@darb wrote:
Oh crap - I thought what I was looking at was someone trying to do the same. I now realize they were converting datasets. Womp. Ok thank you. So I should use command to copy from .sas to .txt?
Let's get back to square one and make some things clear:
Open a cmd window, navigate to path_a with cd, and do
copy *.sas c:\path_b\*.txt
I am sorry, where did you get the idea that .sas programs need to be called .txt? It does not make sense, and is counter-productive. Examine the guidance for industry:
https://www.fda.gov/downloads/ForIndustry/DataStandards/StudyDataStandards/UCM241502.pdf
In particular page 5 of 12, which states:
Any requested programs (scripts) generated by an analysis tool should be provided as ASCII text files and should include sufficient documentation to allow a reviewer to understand the submitted programs. If the programs created by the analysis tool use a file extension for ASCII text files other than .txt, the file name should include the native file extension generated by the analysis tool for ASCII text program files, e.g. myRcode.r, mySAScode.sas, etc. If the analysis tool does not save programs in ASCII format, a PDF rendition of the program file should be provided in addition to the program file
SAS programs should be sent as they are with the file extension .sas. They are plain text files, and are associated with the SAS software.
I had an inkling that this is a result of misunderstanding, or misinterpretation of some guideline.
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.