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
Hope this works for the above problem.
data want;
set have;
if _N_=1 then id=101;
else id+1;
run;
Thanks,
Sudeer.
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.
Thanks for your reply
Don't understand why would you do that.
data have;
set have;
retain n 100;
n+1;
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: