- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
I want to concatenate two character variables in SAS and wishing to include Parenthesis with second variable. I am able to do that with the help of traditional || method but I was wondering if would do that with CAT series functions. I have converted numeric variable to character/string.
Data A;
input;
Date $10. Devdate$ XY$;
datalines;
19JAN1990 23 U/L
23Mar1987 46 U/L
;
run;
I am wishing to see final result with anew variable named ABC and the value should be concatenation of Date and Devdate with parenthesis. Final result should be 19Jan1990(23) but with Cat series functions. Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
length ABC $20;
set a;
ABC=CAT(strip(date),'(',strip(Devdate),')');
run;
Remove leading and trailing blanks before concatenation. CAT() function default length is 200, you can set the length if you don't want the default.
Suryakiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@shanky_44your want is 19Jan190(23) should it be 19Jan1990(23) if so then
Put the ( into quotes like this:
Data A;
input
Date $10. Devdate$ XY$;
datalines;
19JAN1990 23 U/L
23Mar1987 46 U/L
;
run;
data A;
set A;
abc = compress(date||"("||Devdate||")");
run;
If you really want 19Jan190(23) you will need to remove ether the first or second 9 in the incoming date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@VDD wrote:
@shanky_44your want is 19Jan190(23) should it be 19Jan1990(23) if so then
I don't understand this part-19Jan190(23) either
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks VDD!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
length ABC $20;
set a;
ABC=CAT(strip(date),'(',strip(Devdate),')');
run;
Remove leading and trailing blanks before concatenation. CAT() function default length is 200, you can set the length if you don't want the default.
Suryakiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, that was a type error. I am wishing to get final result like 19Jan1990(23) which is concatenation of two variables. Thanks for your reply. It is working. Thanks once again!