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

I want to export the resulted data to be txt, as picture below each variable takes 2 columns, but I want each variable takes 1 column. How should I modify my code?  Thank you!

 

 

proc export data=try outfile='....\data for simultaneous calibration.txt'
dbms=dlm replace; delimiter=' '; putnames=NO;
run;

 

superbug_0-1618842686930.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

We cannot code to photographs.  At a minmum provide TEXT of the desired record.  But in reality provide the detail specification of which variables should appear in which column of the output line.

 

Just learn how to use formats with PUT statement.  Or even column mode output with PUT statement.

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

There is no need to use "export" to create a text file. Just write the file directly.  Then you can have full control over how the values are written.

So if your data has two identifiers and then a series of fifty one digit numbers your data step might look like:

data _null_;
  set try ;
  file '....\data for simultaneous calibration.txt' ;
  put id1 id2 (var1-var50) (1.);
run;
superbug
Quartz | Level 8

@Tom 

Thanks much for your response!

Part of my data looks like following before being exported to .txt

 

superbug_0-1618844165557.png

 

as you suggested, I used the following code (a little change of var names as in bold)

 

data _null_;
set try ;
file '...\data for simultaneous calibration_new.txt' ;
put id1 id2 (JAL000001-JAL000177) (1.);
run;

 

But the .txt file I got is like the following, which is not desired format, 

 

superbug_1-1618844431524.png

 

the highlighted part in the picture above should stay together like following

superbug_2-1618844544004.png

 

any other suggestion, please.

 

Tom
Super User Tom
Super User

We cannot code to photographs.  At a minmum provide TEXT of the desired record.  But in reality provide the detail specification of which variables should appear in which column of the output line.

 

Just learn how to use formats with PUT statement.  Or even column mode output with PUT statement.

ballardw
Super User

Unfortunately PICTURES do not show "columns" worth beans.

Since you have a blank as a delimiter there is a space between values. If you do not want a space between each value then you are not creating delimited data and as such you don't provide delimiters or use DBMS=dlm.

superbug
Quartz | Level 8

@Tom @ballardw 

Thanks much for your suggestions!

I very much appreciate your help!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 5 replies
  • 1282 views
  • 3 likes
  • 3 in conversation