BookmarkSubscribeRSS Feed
Mike_Davis
Fluorite | Level 6

Hello everyone,

Please advise on create dataset two base on dataset one.

finally make all the value with 7 digit, use '0' to fill the left rest part.

Thanks!

Mike

data one;
input x $10. y $10.;
cards;
35179       31804
35178       31804
0032549     31743
0037096     31743
0036617     31743
0035190     31743
0035190     31743
0032549     31743
0032549     31743
35089       100240
35089       100240
35089       100240
0035009     31747
35056       107240
35089       100240
;
run;

data two

0035179       0031804
0035178       0031804
0032549       0031743
0037096       0031743
0036617       0031743
0035190       0031743
0035190       0031743
0032549       0031743
0032549       0031743
0035089       0100240
0035089       0100240
0035089       0100240
0035009       0031747
0035056       0107240
0035089       0100240

1 REPLY 1
Tom
Super User Tom
Super User

If you really have numbers then you can use SAS formats.

data two ;

  set one;

  x=put(input(x,7.),z7.);

  y=put(input(y,7.),z7.);

run;


If you want to change the spaces to zeros and the values aren't really numbers then you might use translate function.

data two ;

   length x y $7.;

  set one;

  x=translate(right(x),'0',' ');

  y=translate(right(y),'0',' ');

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1 reply
  • 551 views
  • 0 likes
  • 2 in conversation