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;

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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