BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jenim514
Pyrite | Level 9

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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:

example.png

Cynthia

View solution in original post

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

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:

example.png

Cynthia

Reeza
Super User

Use CATX instead to concatenate the variables together, it's cleaner and easier to follow.

Ksharp
Super User
class=sys||'/'||'0D0A'x||hiterm||'/'||'0D0A'x|| lowterm;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 933 views
  • 0 likes
  • 4 in conversation