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.
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;
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.
Why? How does dividing data into groups of 20, however you define these groups, help anything?
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 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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.