BookmarkSubscribeRSS Feed
Harish2
Calcite | Level 5

Hi team,

 

I am extracted the data and exporting into .dat format with pipe delimiter after exporting i am getting some extra pipes in the file.Please let me know how to remove that extra pipes while doing export.

 

Example :PIUM_FC |MS|PIUM_MRSC|CO|PIUM_LBC|HCT|PIUM_ATC|PM|MC_CNT1|13|||| 

 

 

Thanks,

Harish

2 REPLIES 2
andreas_lds
Jade | Level 19

please post the code used to export and and excerpt of the data. Are there variables with missing value at the end of the observation?

ballardw
Super User

@Harish2 wrote:

Hi team,

 

I am extracted the data and exporting into .dat format with pipe delimiter after exporting i am getting some extra pipes in the file.Please let me know how to remove that extra pipes while doing export.

 

Example :PIUM_FC |MS|PIUM_MRSC|CO|PIUM_LBC|HCT|PIUM_ATC|PM|MC_CNT1|13|||| 

 

 

Thanks,

Harish


Those "extra pipes" are likely not extra but are related to the last 4 variables exported having missing values.

If they represent variables you do not actually want in the output then DROP them from the export step, if using proc export. If using a data step then don't write them.

Example:

data example;
   x= 'something';
   y=.;
   z=.;
run;

proc export data=example outfile='x:\data\example.txt'
   dbms=dlm replace;
   delimiter='|';
   putnames=yes;
run;

results in

x|y|z
something||

the first "extra" pipe is between X and Y, the second between Y and Z variables.

If later rows of the data set have values for Y and Z they would appear.

More entertaining would be what you would do with "extra" pipes if the X value is missing but Y and Z aren't. If you removed the "extra" leading pipe the value of Y would be treated as that for X in whatever happens next.

 

With probability approaching unity you likely want to keep those pipes.

If not you will need to explain exactly what gets broken when they are present with missing values.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 804 views
  • 0 likes
  • 3 in conversation