Help using Base SAS procedures

help on create dataset two base on one

Reply
Regular Contributor
Posts: 222

help on create dataset two base on one

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

Super User
Super User
Posts: 6,500

Re: help on create dataset two base on one

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;

Ask a Question
Discussion stats
  • 1 reply
  • 132 views
  • 0 likes
  • 2 in conversation