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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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