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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.