BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Tecla1
Quartz | Level 8

Good morning,

I need to insert a label with a line breack, is possible? I have to replicate an export in Excel with column headers that contain newlines like this:

"Matr.
S.I."

Please can you help me? I tried but in any case in te export results without a line breack....

many thanks to all. 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Below one option.

data work.have;
  col1='ABC';
  col2=123;
run;

ods excel file="c:\temp\yourfile.xlsx";

%let lbl=Matr.%sysfunc(inputc(0A,hex.))S.I.;
proc print data=have label;
  label col1="&lbl";
run;

ods excel close;

Patrick_0-1732530222398.png

 

 

View solution in original post

7 REPLIES 7
sbxkoenk
SAS Super FREQ
Patrick
Opal | Level 21

Below one option.

data work.have;
  col1='ABC';
  col2=123;
run;

ods excel file="c:\temp\yourfile.xlsx";

%let lbl=Matr.%sysfunc(inputc(0A,hex.))S.I.;
proc print data=have label;
  label col1="&lbl";
run;

ods excel close;

Patrick_0-1732530222398.png

 

 

Tecla1
Quartz | Level 8
Thanks everyone, I received great help!! I'll try the solutions right away !!! have a nice dat: Tecla
Tecla1
Quartz | Level 8

Good morning everyone, I have verified your solution for which I thank you, but I have a problem: if the width of the excel cell is sufficiently wide the text dos not wrap. I need an action equal the excel comand "ALT + ENTER"  to insert a line break, is it possible? It's very important for me... otherwise I'll have to reorganize a rather large DB.... Tnks!!  

PaigeMiller
Diamond | Level 26

How are you creating an Excel file? Please show us the code.

 

If you are using PROC REPORT or PROC PRINT, there is the SPLIT= option which causes line breaks exactly where you want them to be. To have the text wrapped, there is also the FLOW= option in ODS EXCEL and the option in ODS EXCEL tagattr='wraptext:yes'

 

So to modify @Patrick 's code to use the SPLIT= option

 

ods excel file="c:\temp\yourfile.xlsx";

proc print data=have label split='~';
  label col1="Matr.~S.I";
run;

ods excel close;
--
Paige Miller
Tecla1
Quartz | Level 8
Many Tnks I regeived a big help !!! I think I have tu study very mach now !! SaS Community is the best!
Tecla1
Quartz | Level 8
Excuse for mistake ... I need to sleep...

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 7 replies
  • 3669 views
  • 4 likes
  • 4 in conversation