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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.