Hi, I have some question
Now, I have X , Y , Z
and need to create new Xcode , Ycode , Zcode
How to coding on SAS, can I use proc sql ?
Thankyou so much
If x, y and z are numeric, this should give the expected result:
data want;
set have;
length xCode yCode zCode 8;
format xCode yCode zCode z2.;
xCode = x;
yCode = y - 10 * x;
zCode = z - 10 * y;
run;
We can't write code using a picture as data source, so please post data in usable form (a data step using datalines), so that we have all the information required to help you.
Why do you want to use proc sql?
Sorry please find
data have;
infile datalines delimiter=',';
input X $ Y $ Z $ ;
datalines;
1,12, 124
3,33,334
10,101,1018
5,54,543
9,94,943
2,28,286
4,47,471
3,35,352
4,48,484
10 102 1027
;
run;
If x, y and z are numeric, this should give the expected result:
data want;
set have;
length xCode yCode zCode 8;
format xCode yCode zCode z2.;
xCode = x;
yCode = y - 10 * x;
zCode = z - 10 * y;
run;
Thankyou so much.
Are you sure that is even possible?
It looks like you want to pull out the least significant digit.
But then you have this line with X=4 Y=47 and Z=4710.
Can any of the three codes be more than one digit? If so how to you determine where to set the boundaries?
What if you have Z=1111 is that 1,1,11 ? or perhaps 1,11,1 or perhaps 11,1,1.
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.