BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ekapat
Calcite | Level 5

Hi, I have some question

 

Now, I have X , Y , Z 

and need to create new Xcode , Ycode , Zcode

 

Ekapat_0-1736841416866.png

 

How to coding on SAS, can I use proc sql ?

 

Thankyou so much

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

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;

View solution in original post

5 REPLIES 5
andreas_lds
Jade | Level 19

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?

 

Ekapat
Calcite | Level 5

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;

andreas_lds
Jade | Level 19

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;
Tom
Super User Tom
Super User

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 627 views
  • 0 likes
  • 3 in conversation