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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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