Hi
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
30(ml)
Instead of getting it in one line : adma;j;j;jkfddddddddddddd 30(ml).
Don't know why. Can someone please help with this?
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.
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.
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'); run;
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.