- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 02-01-2022 05:27 AM
(483 views)
hi,
Ive two column (Char,Code) and I just want to combine them (into result). But how? Could you pls help me with SAS- and SQL-command? Thank you!
Char | Code | Result |
KA | 14523 | KA14523 |
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Result = cats(Char, Code);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If your code variable is numeric you need to consider cases of differing number of digits and what you expect for the result. If you always want 5 digits in the combined value and the Code value is less than 10000 you may need to control the conversion to character as the default may not yield the desired need.
data example; char ='ABC'; code = 3; combined= cats(char,code); combined2 = cats(char,put(code,z5.)); put combined= combined2=; run;
Yields:
combined=ABC3 combined2=ABC00003
The automatic conversion to character for the CAT (and most functions) will use a BEST format which may have fewer digits than you want/need/expect.