Desktop productivity for business analysts and programmers

Character and numeric

Reply
Occasional Contributor
Posts: 18

Character and numeric

I am in EG 4.2 and forgot how to combine a numeric and character string. Somebody sent me data with a three letter prefix in one column and the number suffix in another. What do i do to recombine II does not seem to work.
Super Contributor
Super Contributor
Posts: 3,174

Re: Character and numeric

Explore using the various CAT-related functions in a DATA step.

Scott Barry
SBBWorks, Inc.
SAS Employee
Posts: 149

Re: Character and numeric

If you're using PROC SQL code (and that means if you're writing an expression in the query builder too!!), just a warning that SAS won't do automatic conversion of numeric to character. You'd want a PUT function for that. There's a nice example here (PUT function is about 2/3 down the page):

http://support.sas.com/kb/35/315.html

Once a PUT function does the conversion work in the expression, you could use "||" as you suggest to conbine the strings. You could also use a function like CATS. Something like...

CATS(t1.prefix,PUT(t1.number,4.))
Respected Advisor
Posts: 3,837

Re: Character and numeric

No need to use the inner put() with cats().
Cats() digests both character and numeric.
Ask a Question
Discussion stats
  • 3 replies
  • 119 views
  • 0 likes
  • 4 in conversation