03-17-2014 01:21 AM
In below example, I would like to create a new character variable and with the attributes of second variable(FMTNAME)!! Resulting variable is RESULT_C.
Thanks in Advance,
03-17-2014 02:17 AM
You will probably also need a Length statement:
Data want ;
set have ;
Length result_C $ 5 ;
result_C = PUTN (result_N, fmtname) ;
keep result_C ;
03-17-2014 05:40 PM
The PUT functions PUT(), PUTN(), and PUTC(), are the SAS conventional methods for recasting or recoding values. PUTN() and PUTC() (for character values) allow the format to be provided dynamically, as you require in this case.
@RW9's amendment , or the use of the LEFT() function, is required if you use the modified version I supplied.
Need further help from the community? Please ask a new question.