Must I convert a numeric variable to a character variable prior to running CAT?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Must I convert a numeric variable to a character variable prior to running CAT?

Hi All,

 

I am using SAS 9.4 (English). I want to concatenate a numeric variable (call it num_var) and a character variable (call it char_var) as follows:

 

wanted = cat(char_var,num_var); run;

I understand that CAT concatenates character variables. Here is my question: Must I convert the numeric variable to a character variable prior to running CAT? Or, does SAS convert the numeric variable to a character variable when I run the code?

 

Thanks for your help.

 

Tristan


Accepted Solutions
Solution
2 weeks ago
Grand Advisor
Posts: 17,308

Re: Must I convert a numeric variable to a character variable prior to running CAT?

CAT/CATT/CATX/CATS level of functions does do the automatic conversion, but it uses the BEST format, not the format applied to the data.

 

This type of information will be laid out in the documentation.

 

item

specifies a constant, variable, or expression, either character or numeric. If item is numeric, then its value is converted to a character string by using the BESTw. format. In this case, leading blanks are removed and SAS does not write a note to the log.

 

http://support.sas.com/documentation/cdl/en/lefunctionsref/69762/HTML/default/viewer.htm#p0wism8jqta...

View solution in original post


All Replies
Solution
2 weeks ago
Grand Advisor
Posts: 17,308

Re: Must I convert a numeric variable to a character variable prior to running CAT?

CAT/CATT/CATX/CATS level of functions does do the automatic conversion, but it uses the BEST format, not the format applied to the data.

 

This type of information will be laid out in the documentation.

 

item

specifies a constant, variable, or expression, either character or numeric. If item is numeric, then its value is converted to a character string by using the BESTw. format. In this case, leading blanks are removed and SAS does not write a note to the log.

 

http://support.sas.com/documentation/cdl/en/lefunctionsref/69762/HTML/default/viewer.htm#p0wism8jqta...

Occasional Contributor
Posts: 8

Re: Must I convert a numeric variable to a character variable prior to running CAT?

Thank you for the assistance, Reeza.
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 96 views
  • 0 likes
  • 2 in conversation