BookmarkSubscribeRSS Feed
RameshReddy
Calcite | Level 5

Dear Team,

kindly any one helpon below issue...

Exporting sas data set to .txt format  with delimiter as '|'

character value where ever null must replace with 8 space between two delimiter

ie., example

Name No Sal

Rajesh|2563|5600

Kumar|5698|6580

           |4568|7560

Abcde|4812|2461

Can it is possible

Thanks in advance,

Ramesh Reddy

3 REPLIES 3
art297
Opal | Level 21

You could always just force it.  E.g.:

data have;

  input Name $ No Sal;

  cards;

Rajesh 2563 5600

Kumar 5698 6580

. 4568 7560

Abcde 4812 2461

;

data _null_;

  file "c:\outpipe.txt";

  set have;

  if missing(Name) then do;

    want=catt('|',No,'|',Sal);

    put @9 want;

  end;

  else do;

    want=catx('|',Name,No,Sal);

    put want;

  end;

run;

Howles
Quartz | Level 8

Maybe

   file  ...  dlm= '|' ;

   put name $8.  '|' no sal ;

The results should look like this:

Rajesh  |2563|5600

Kumar   |5698|6580

        |4568|7560

Abcde   |4812|2461

Ksharp
Super User

You can always change it after importing it.

data have;
  input Name $ No Sal;
  cards;
Rajesh 2563 5600
Kumar 5698 6580
. 4568 7560
Ab 4812 2461
;
run;


data _null_;
 set have ;
 file 'c:\x.txt' dlm='|';
 put (_all_) (~);
run;
data _null_;
 infile 'c:\x.txt';
 file 'c:\want.txt';
 input;
 _infile_=prxchange('s/ (?=\|)/        /o',-1,_infile_);
 put _infile_;
run;


Ksharp

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 880 views
  • 1 like
  • 4 in conversation