Hi all,
I've got some conditions and dates I'd like to process and make new observations from.
For example, I'm starting from the following:
data have; input cond1 cond2 start end; datalines; 1 0 4075 4965
1 0 5025 5763 0 1 4333 5322 ; run;
And I'd like to process the above such that I get the following:
data want;
input cond1 cond2 start end;
datalines;
1 0 4075 4333
1 1 4333 4965
0 1 4965 5025
1 1 5025 5322
1 0 5322 5763
;
run;
Of course there are several more possible permutations to this as start and end are date variables that can vary in range between the conditions, but I'll only be handling 2 conditions at a time.
I was wondering if SAS could utilize multiple output statements within a conditional step in order to output multiple observations? I'm also happy to hear other strategies of approach as well. Thus far I've been sorting and my data many different ways to try to get a handle on how best detect and create new observations, but have had a lot of trouble coming up with a solution that fits even just the above situation. I'm wondering if I should give each condition their own set of date variables and attempt to reconcile them from there.
Many thanks!
While I don't quite understand your algorithm, the answer is definitely yes, you can output conditionally to whatever data set you want.
Example:
data boys girls;
set sashelp.class;
if sex='F' then output girls;
else if sex='M' then output boys;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.