Help using Base SAS procedures

i want a code for below data

Reply
Occasional Contributor
Posts: 12

i want a code for below data

suppose dataset contains variable 'name'


name

sri

ram

ragu

a

b

c

d

e

f

g

h

i

j

quest: we want to create another dataset in way that we should create another vaiable 'id'  i want to assign values in an order automatically to variable 'id' like for 1st variable 101 ,2nd variable 102  and so on  if we have 100 variable values the first 'id' value should be 101 and last 'id' variable should be 200  

name id 

sri  101

ram  102

ragu 103

a    104

b    105

c    106

d    107

e    108

f    109

g    110

h    111

i    112

j    113

i

Contributor
Posts: 29

Re: i want a code for below data

Hope this works for the above problem.

data want;

set have;

if _N_=1 then id=101;

else id+1;

run;

Thanks,

Sudeer.

Respected Advisor
Posts: 3,777

Re: i want a code for below data

Would it be a good idea to make the ID character?  It might help to indicate the purpose and prevent it from being used as a measure.

Occasional Contributor
Posts: 12

Re: i want a code for below data

Thanks for your reply

Super User
Posts: 9,687

Re: i want a code for below data

Don't understand why would you do that.

data have;

set have;

retain n 100;

n+1;

run;

Ask a Question
Discussion stats
  • 4 replies
  • 242 views
  • 0 likes
  • 4 in conversation