Hi,
I have 2 sas datasets:
Var_1 = Visits Var_2 = Types
1 x1, x1, ....x1x2, x1x2
2
3
.....
...... 49, 50
its like, I have visits 1- 50 and Types x1 and x1x2
So, If visits 1- 16 then Its x1 type
and if visits 17-50 then its x1x2 type
so, I need to create a dataset which says,
If visits 1-16 and x1 then D= Finish
if visits 0 then D = Not Finish
and
If visits 17-50 then its D2 = Finish
If visits 0 hten its D2 = Not Finish
Thanks,
Here's a few ways to check conditions that can help you get started.
If you're checking for a range use
if 1 <= Var_1 <= 17 and VAr_2 in ('X1' 'X2') then D='Finish';
If you're checking integers you can also use the following: where 1:17 is 1 to 17 inclusive, but integers only.
if var_1 in (1:17) and var_2 in ('X1', 'X2') then D1 = 'Finish';
else if var_1 in (18:50) and var_2 not in ('X1' 'X2') then D1 ='Started';
else D1 = 'Not Finished';
Note the IN as well to check multiple values at once, that can be for character or numeric values.
Not really sure what you mean about 'more observations', you need to clarify that.
In general, I think this gives you the tools to answer your question.
@sharuu_00 wrote:
Hi,
I have 2 sas datasets:
Var_1 = Visits Var_2 = Types
1 x1, x1, ....x1x2, x1x2
2
3
.....
...... 49, 50
its like, I have visits 1- 50 and Types x1 and x1x2
So, If visits 1- 16 then Its x1 type
and if visits 17-50 then its x1x2 type
so, I need to create a dataset which says,
If visits 1-16 and x1 then D= Finish
if visits 0 then D = Not Finish
and
If visits 17-50 then its D2 = Finish
If visits 0 hten its D2 = Not Finish
Thanks,
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.