Hi!
I have three variables, that need to be joined to one variable and output to new line separate by backslash. Sorry...so weird to explain!!
I tried:
data final1;
length class $300.;
set final;
class=sys||'/'||'~n/'||hiterm||'/'||'~n/'|| lowterm;
run;
proc print data=final1;
run;
I need to one variable 'class' with concatenated values of sys, hiterm,lowterm on unique line when '/' encountered:
CLASS
sys/
hiterm/
lowterm
or sample data output
CLASS
Investigation/
Metabolism/
Hyperglycemia
Hi:
You only show one statement. You don't show the rest of your code. Are you using PROC PRINT, PROC REPORT??
You don't show any ODS statement -- I guess that you are using ODS because ~n is the old ESCAPECHAR way of inserting a new line into a text string to show line breaks in ODS HTML, RTF or PDF output. But not all destinations use ESCAPECHAR, so it would be useful to see more code.
Here's an ODS HTML example using the new ESCAPECHAR syntax and showing the output:
Cynthia
Hi:
You only show one statement. You don't show the rest of your code. Are you using PROC PRINT, PROC REPORT??
You don't show any ODS statement -- I guess that you are using ODS because ~n is the old ESCAPECHAR way of inserting a new line into a text string to show line breaks in ODS HTML, RTF or PDF output. But not all destinations use ESCAPECHAR, so it would be useful to see more code.
Here's an ODS HTML example using the new ESCAPECHAR syntax and showing the output:
Cynthia
Use CATX instead to concatenate the variables together, it's cleaner and easier to follow.
class=sys||'/'||'0D0A'x||hiterm||'/'||'0D0A'x|| lowterm;
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.