Hello All,
I have dataset A
datalines age race sex county population
1 W F Adams 139
Here population 139 is the aggregate of that age, sex, race, and county.
What I want to do is replicate that above combination to 138 rows to reflect as row level data. Any help is really appreciated?
Thank you!
A simple DO loop:
data want;
set have;
do i = 1 to population;
population = 1;
output;
end;
drop i;
run;
Do you want to split this observation into 138 observations which sum up to 139?
Yes, that is right. Thank you! Any help would be great.
So you want 137 observations with a value of 1 and one observation with a value of 2?
So, it is actually 138 observations with that combination of age, race, sex etc. I have sum for each combination in my data already. I need to expand or split those into rows based on that number. Thank you!
A simple DO loop:
data want;
set have;
do i = 1 to population;
population = 1;
output;
end;
drop i;
run;
Thank you, Sir! This worked. Much appreciated.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.