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

Hi,

I have a table with 5 rows and one column, the columns are formatted in $32759 (maximum allowed).
I need to export this table to txt format but it needs to be all in one row. If I do the proc export or data _null_ file and open the final file, for example with notepad++, I see that there are 5 rows. I have also tried transposing but I always have the same problem.

 

How can I do this? Obviously without using xcommand.

 

Thanks a lot!

1 ACCEPTED SOLUTION

Accepted Solutions
japelin
Rhodochrosite | Level 12

how about this.

Use put statement with @.

 

data have;/* sample */
  length vars $32759;
  do i=1 to 5;
    vars=put(i,best.);
    output;
  end;
  drop  i;
run;

filename out temp ;
data _null_;
  set have;
  file out LRECL=163795;
  put vars @;
run;

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19

Try something like this:

data _null_;
   set sashelp.class(keep=Name) end=lastObs;
   file "onerow.txt";
   
   if not lastObs then put Name @;
   else put Name;
run;
japelin
Rhodochrosite | Level 12

how about this.

Use put statement with @.

 

data have;/* sample */
  length vars $32759;
  do i=1 to 5;
    vars=put(i,best.);
    output;
  end;
  drop  i;
run;

filename out temp ;
data _null_;
  set have;
  file out LRECL=163795;
  put vars @;
run;
Ksharp
Super User

Check RECFM=N option of INFILE or FILENAME ,which could excess the limit of 32767.

 

data _null_;
set sashelp.class;
file 'c:\temp\want.txt' recfm=n;
put (_all_) (:);
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 557 views
  • 0 likes
  • 4 in conversation