BookmarkSubscribeRSS Feed
Fluorite | Level 6


I need to concatenate two variables.

Example:        treatment                                      Dose

                      adma;j;j;jkfddddddddddddd          30(ml)


Both are characters. I tried to concatenate them using " || ".  But Im getting like this  :  adma;j;j;jkfddddddddddddd  


 Instead of getting it in one line :   adma;j;j;jkfddddddddddddd   30(ml).


Don't know why. Can someone please help with this?

Diamond | Level 26 RW9
Diamond | Level 26

Is there a special chaaracter in either of those strings?  (Can happen when importing from Excel for instance).  Posting test data in the form of a datastep would go a long way to explaining it.  Follow this post on how to provide test data:


Currently there is not much to suggest apart from compressing out special characters:

dose=compress(dose, "0a"x);

Is one, but there are others.

Fluorite | Level 6
No. There is no special character.
Diamond | Level 26 RW9
Diamond | Level 26

And how do you know.  More importantly, how do we know.  We cannot see your system, or your data, or in fact what you are doing, or what you are getting out.  None of this information has been provided, hence we cannot help.  Provide test data in the form of a datastep.  Show what you are doing, then show log and output.

Super User

When you use the || operator unless you specifically trim or strip a variable then the variable is padded to its assigned length.

Please look at the results of this example:

data example;
   length x $ 25 long y z $ 50;
   x= 'short';
   long= x||' word';
   y = strip(x)||' word'  ;
   z = catt(x,' word');

the CATT function (and related CATS) may be better choices than the || operator.


With out showing how you are getting that result it may be that the split line behavior is attempting to show 50 or 60 characters in a table or view that is only 20 or so wide and so the result is wrapping.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 3 in conversation