BookmarkSubscribeRSS Feed
chittamsri1_gmail_com
Calcite | Level 5

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

4 REPLIES 4
Chrishi
Calcite | Level 5

Hope this works for the above problem.

data want;

set have;

if _N_=1 then id=101;

else id+1;

run;

Thanks,

Sudeer.

data_null__
Jade | Level 19

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.

chittamsri1_gmail_com
Calcite | Level 5

Thanks for your reply

Ksharp
Super User

Don't understand why would you do that.

data have;

set have;

retain n 100;

n+1;

run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1324 views
  • 0 likes
  • 4 in conversation