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

Hi,

 

In our SAS dataset which we have extracted the data from SAS , we have value as like below

 

"QWERTY
, xxx/ABCc Financial Services Ltd/XYX Wealth Limited"

 

not in a single line.  When I proc export the dataset into a txt file , the line is getting broken and the below one (xxx/ABCc..) as a separate row in the txt file.

 

How to rectify the problem?? I think we have to resolve in the SAS dataset load rather than in proc export.

 

I have used compress = yes while creating the work.dataset but nothing works.

 

Please let me know the solution for this? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

You may have linefeeds in your data. Inspect the column in which the line break happens by displaying it with a $HEX format (format length must be double the defined variable length).

Linefeeds are hex 0A, carriage returns 0D.

If that is the case, use the TRANSLATE function to replace these special characters with blanks.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

You may have linefeeds in your data. Inspect the column in which the line break happens by displaying it with a $HEX format (format length must be double the defined variable length).

Linefeeds are hex 0A, carriage returns 0D.

If that is the case, use the TRANSLATE function to replace these special characters with blanks.

helannivas88
Obsidian | Level 7

Thanks Both.

 

The issue is with the line feed (Hex value - 0A). I have used compress function to resolve the issue.

 

NAME= compress(NAME, ,'kw');

Tom
Super User Tom
Super User

SAS does not know how to read (or write) delimited files with end of line characters embedded into the value of a variable.

 

Best solution is to remove those characters from the value before writing the delimited file.  For example by replacing them with spaces.

data for_export;
  set have;
  array _c _character_;
  do over _c;
    _c = translate(_c,'  ','0A0D'x);
  end;
run;

proc export data=for_export dbms=csv
  file='want.csv'
;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4207 views
  • 0 likes
  • 3 in conversation