Convert Program to TXT file

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

Convert Program to TXT file

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!


Accepted Solutions
Solution
‎04-18-2018 10:23 AM
Super User
Posts: 10,280

Re: Convert Program to TXT file

Open a cmd window, navigate to path_a with cd, and do

copy *.sas c:\path_b\*.txt
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Super User
Super User
Posts: 9,599

Re: Convert Program to TXT file

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

Occasional Contributor
Posts: 19

Re: Convert Program to TXT file

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!

Super User
Posts: 10,280

Re: Convert Program to TXT file

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?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 19

Re: Convert Program to TXT file

Posted in reply to KurtBremser

It's required by the FDA

Super User
Super User
Posts: 8,127

Re: Convert Program to TXT file

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.

Occasional Contributor
Posts: 19

Re: Convert Program to TXT file

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

 

Super User
Posts: 10,280

Re: Convert Program to TXT file

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 19

Re: Convert Program to TXT file

Posted in reply to KurtBremser
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?
Super User
Posts: 10,280

Re: Convert Program to TXT file


@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?
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 19

Re: Convert Program to TXT file

Posted in reply to KurtBremser
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.
Solution
‎04-18-2018 10:23 AM
Super User
Posts: 10,280

Re: Convert Program to TXT file

Open a cmd window, navigate to path_a with cd, and do

copy *.sas c:\path_b\*.txt
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 19

Re: Convert Program to TXT file

Posted in reply to KurtBremser
great, thanks!
Super User
Super User
Posts: 9,599

Re: Convert Program to TXT file

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.

 

Super User
Posts: 10,280

Re: Convert Program to TXT file

I had an inkling that this is a result of misunderstanding, or misinterpretation of some guideline.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 16 replies
  • 398 views
  • 8 likes
  • 4 in conversation