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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.