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;
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.
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;
Thanks much for your response!
Part of my data looks like following before being exported to .txt
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,
the highlighted part in the picture above should stay together like following
any other suggestion, please.
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.
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.
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.
Ready to level-up your skills? Choose your own adventure.