Hi all,
I have a dataset with 5472 observations but I would like to split it up into two datasets with 2736 observations each. I would like to do this by keeping the first 12 observations for the first dataset and the second 12 for the second, third 12 for the first, fourth 12 for the second, and so on. Is there a succinct way to do this? I am aware of the mod function but that only returns every nth value. Any help is appreciated.
I'm not sure this is elegant, but it works:
data want1 want2;
do _n_=1 to 12;
link retrieve;
output want1;
end;
do _n_=1 to 12;
link retrieve;
output want2;
end;
return;
retrieve: set have;
return;
run;
By using the same SET statement, both loops continue reading the next observation, then the next, etc.
12 makes me think it's monthly data, is there perhaps another variable that would identify the groups? If so, there are ways to make this entirely data driven.
Hi Reeza,
No it is not monthly data. I had PROC MCMC output simulated data from the posterior distribution for predicted values. Each individual (N = 228) had observations representing a quantitative task and a verbal task, thus my wanting to separate each individual's observations into a quantitative dataset and a verbal dataset. Thank you for your help!
@tbanh wrote:
Hi Reeza,
No it is not monthly data. I had PROC MCMC output simulated data from the posterior distribution for predicted values. Each individual (N = 228) had observations representing a quantitative task and a verbal task, thus my wanting to separate each individual's observations into a quantitative dataset and a verbal dataset. Thank you for your help!
Do you have a variable that indicates if it's qualitative or quantitative? Trusting an implied order is a risky game.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.