DATA A;
X=1230;
Y=PUT(X,Z6.);
Y1=INT(LOG10(X)+1);
Y2=SUBSTR(LEFT(10**(6-Y1)),2);
Y3=CATS(Y2,X);
RUN;
output is:x-1230
y-001230
y1-4
y2-00
y3-001230
so i wanted to know how this program is working
in line Y2=SUBSTR(LEFT(10**(6-Y1)),2);,what is the use of "10**",how this is working and what impact it has on the numbers.
and how it got to know that it had to substract 4 from y1 without refrencing y .
The key statement is here
Y1=INT(LOG10(X)+1);
LOG10(X) means get the power of X by 10 .
For example :
x=12300;
INT(LOG10(X)) will get 4 ,which is power of X ( 10^4=10000).
The key statement is here
Y1=INT(LOG10(X)+1);
LOG10(X) means get the power of X by 10 .
For example :
x=12300;
INT(LOG10(X)) will get 4 ,which is power of X ( 10^4=10000).
@Ksharp wrote:
For example :
x=1230;
INT(LOG(X)) will get 4 ,which is power of X ( 10^4=10000).
You mean INT(LOG10(X)+1).
Apparently, lines 4 - 6 of this data step are an attempt to replicate the result obtained in line 3, but without using PUT function and Z6. format.
The plan is:
However, it must be said that this is poor programming style.
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.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.