BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
darb
Calcite | Level 5

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!

1 ACCEPTED SOLUTION
16 REPLIES 16
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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"?

darb
Calcite | Level 5

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!

Kurt_Bremser
Super User

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?

darb
Calcite | Level 5

It's required by the FDA

Tom
Super User Tom
Super User

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.

darb
Calcite | Level 5

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);

 

Kurt_Bremser
Super User

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
Calcite | Level 5
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?
Kurt_Bremser
Super User

@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:

  • programs or datasets?
  • from where to where?
  • and why change the extension to .txt, if it's not data but program code?
darb
Calcite | Level 5
Ok. I have several hundred SAS programs with .SAS extensions. The FDA requires for submissions that SAS program files be submitted with .TXT extensions. So I am looking for a more efficient way to convert all of the .SAS programs in Folder A to .TXT programs in Folder B.
darb
Calcite | Level 5
great, thanks!
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 16 replies
  • 14773 views
  • 9 likes
  • 4 in conversation