BookmarkSubscribeRSS Feed
KevinC_
Fluorite | Level 6
Hello all,

I thougth the PUT( ) function converts a variable from numeric to character. Am I wrong?

Does the following code convert a variable from numeric to character?


if Loan_No2 ne ' ' and loan_no2 ne 'NULL' then do;
numer_eloc_loan_num=Loan_No2;
eloc_loan_num=put(numer_eloc_loan_num,z10.);
end;
else do;
numer_eloc_loan_num=0;
eloc_loan_num=put(numer_eloc_loan_num,z10.);
end;

Thanks for any input !
3 REPLIES 3
KevinC_
Fluorite | Level 6
I guess I am confused about the "z10" in the ( ). Z10 (numeric) is the format being converted from. Is that right?

Thanks.
Flip
Fluorite | Level 6
As long as eloc_loan_num is a character variable the z10. will put the number in as character keeping leading zeros.
DanielSantos
Barite | Level 11
put function will return a character representation of a numeric OR character value (variable, constant or expression) using a specified format (which must match with the source type value).

Things to remind:
- put function always returns a character value.
- the format specified must be of the same type of the source value.

data _null_;
X=put('XXXXX',$2.); * char to char;
Y=put(23,Z5.); * num to char;
put _all_;
run;

Check the online documentation here:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000199354.htm

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 4562 views
  • 0 likes
  • 3 in conversation