- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hey all, I have the following:
(case when t1.Line_Number=1 then
"The big brown dog jumped over the red fence. Then went to bed"
end) AS Special_Instructions;
Is there a special character in SAS to insert a carriage return after the period by the word "fence" ? I would like to be able to export these and similar comments into Excel as labels, but some will need carriage returns. Not sure SAS has a code to enter within the quote that will export a carriage return, or even make a carriage return within the SAS text variable. thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can insert any hexcode you want. The hexcode for CR is '0D'x.
(case when t1.Line_Number=1 then
'The big brown dog jumped over the red fence.'||'0D'x||'Then went to bed'
end) AS Special_Instructions;
I also changed the qutoes to single quotes so that you could also insert characters like & and % that would be macro triggers if enclodes in double quotes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Have you tried a '\r' or used the ASCII equivalent ('13'x)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure where to place those within my quote. I have tried \r, '\r' to no avail and am unsure how to enter the ascii. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I foudn this in another thread. To get the valid hex, use this:
cr=input('0D',$hex2.);
Note: 0D == '13'
A valid SAS statement would be:
x = "Test the carriage return" || cr || right now" ;
See if that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can insert any hexcode you want. The hexcode for CR is '0D'x.
(case when t1.Line_Number=1 then
'The big brown dog jumped over the red fence.'||'0D'x||'Then went to bed'
end) AS Special_Instructions;
I also changed the qutoes to single quotes so that you could also insert characters like & and % that would be macro triggers if enclodes in double quotes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you want nice readbale output in excel then using a reporting procedure is the way to go:
ods excel file="c:\xyz.xlsx"; proc report data=have nowd split="~"; columns _all_; define var1 / label="Something here~which needs~Splitting"; ... run; ods excel close;
Its rarely a good idea to put things in the data which have no purpose other than for reporting (it just makes processing the data harder).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Tom's response was partially correct. Excel does not honour the carriage return, Word does though. When I used "new line" Excel then honored it (Word as well):
case when t1.Line_Number=1 then 'The big brown dog jumped over the red fence.' ||'0A'x|| 'Then went to bed' end