BookmarkSubscribeRSS Feed
TPlevney17
Calcite | Level 5

Hi everyone,

 

My task is to modify an existing SAS program file by adding a line for version control each time our programs are validated. I have a program in place that currently is able to read in the original .SAS file as a SAS dataset with one column. I do some manipulation to achieve the required program text for the new program version but do not know how to export this dataset column to a .SAS file. I know that .SAS files are essentially just .TXT files, so I am trying to use proc export to output this column to a .TXT file and will then convert the .TXT file to a .SAS file using %sysexec commands.

 

Here is the code that I am currently using:

filename file_out "C:\test.txt";
proc export data=final
outfile= file_out
dbms=dlm replace;
delimiter='';
putnames=no;
run;

 

However, this code is outputting a .TXT file that has quotes wrapped around all records that are not "stripped". Is there a way to get around this and have the proc export respect records with leading tabs or spaces and not modify the string to contain extra quotations?

 

Thank you

2 REPLIES 2
ballardw
Super User

Please show some data and what the expected file should look like.

Proc export may not be the proper tool.

If by column you mean a variable try this:

 

data _null_;
   set final;
   file file_out;
   put variablename;
run;

You should have looked in the log and seen something similar to this there.

If your variable is really long you might have to set the LRECL= on the FILE statement to a value long to hold a long string.

 

If the file is actual a SAS program file is there a reason you do not name it with the .SAS extension?

TPlevney17
Calcite | Level 5

Thank you for your reply. After playing around for a while I was able to get the file to output correctly while respecting the leading tabs and spaces with the following code:

TPlevney17_1-1615481959209.png

 

 

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 2 replies
  • 1595 views
  • 0 likes
  • 2 in conversation