BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Discaboota
Obsidian | Level 7

Hey guys, I am new to SAS and I have learned a lot from this community.
I want to divide the data of 4.5 million from a column into groups of 20, doesn't matter about the number of groups but the data keeps on increasing every day by around 10k so I need to code it so that my code can cope with increasing data.
Please Help. Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Not sure what you mean by divide?  Do you want to assign a GROUP variable?  Does it need to be random assignment?

 

If not then simply use their position in the dataset.

data want;
  set have;
  group = ceil(_n_/20);
run;

 

View solution in original post

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

Groups of 20 what?

 

Also, why do you want to split up your data? SAS can easily handle a data set of 4.5M obs.

Discaboota
Obsidian | Level 7
Hey, I am required to provide unique leads of 20 customers every day to every sales officer my bank has, so I was thinking of dividing it into groups of 20 and then providing the leads to them sequentially.
If I can do it in a better way then please let me know.
PaigeMiller
Diamond | Level 26

Why? How does dividing data into groups of 20, however you define these groups, help anything?

--
Paige Miller
Tom
Super User Tom
Super User

Not sure what you mean by divide?  Do you want to assign a GROUP variable?  Does it need to be random assignment?

 

If not then simply use their position in the dataset.

data want;
  set have;
  group = ceil(_n_/20);
run;

 

Discaboota
Obsidian | Level 7
Thank you Tom for your help, it is what I was looking for. I am thinking of dividing the data into groups so that I can deliver groups sequentially to the required person.
ballardw
Super User

@Discaboota wrote:
Thank you Tom for your help, it is what I was looking for. I am thinking of dividing the data into groups so that I can deliver groups sequentially to the required person.

If the original sequence is needed then perhaps the below. This increments a counter every 20 observations.

data want;
  set have;
  retain group 1;
  if mod(_n_,20)=0 then group+1;
run;
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1851 views
  • 2 likes
  • 5 in conversation