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