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!
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.
Have you tried a '\r' or used the ASCII equivalent ('13'x)?
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?
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.
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.
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).
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
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 25. Read more here about why you should contribute and what is in it for you!
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.