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;

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