BookmarkSubscribeRSS Feed
cindyforest7
Calcite | Level 5


Hi,

Now I have a table with 5000 contracts and each contract has different membership. There is a metric measuring the performance of that contract.

Contract_id      membership      metric

H4510               2000                  90%

H0028               5230                  80%

H2309               2341                  95%

.....                    .....                      .....

Now I want to replicate each contract row by membership-times. For example, replicate the first row (H4510) by 2000 times and second row (H0028) by 5230 times and so on.

Does anyone know how to do that?

Thank you so much!

2 REPLIES 2
RaviKommuri
Fluorite | Level 6

You can use this.....

data have;                       

Input contid $ membship metric $;

datalines;                       

H4510 2 90                       

H0028 5 80                       

H2309 2 95                       

;                                

data want(drop=i);               

set have;                        

do i=1 to membship;              

output;                          

end;                             

run;                             

ballardw
Super User

For many analysis steps you may be able to use your membership variable as a FREQ variable.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 1363 views
  • 0 likes
  • 3 in conversation