Hello team,
I code as follows:
if member_ID in ('k') then tempbucket = 'Health plan v';
Proc sql;
create table mydata as
select distinct a.member_ID
from tablec a;
quit;
Now I want to add this tempbucket to my table.
Can you please let know how?
I have searched a lot!
Regards,
Blue Blue
How can I do that?
Thanks for the response.
Let me try it tomorrow and I will get back to you:
Does this add a new variable? Or test different cases? Anyway, case statement can solve my situation.
If it is not "k only" it is "k" or "n", then what happens? I mean to use "or" with "in".
Can we bring our new variable after the word "case"?
Proc sql; create table mydata as select distinct a.member_ID ,case when a.member_ID in ('k') then 'Health plan v' else '' end as tempbucket from tablec a; quit;
Regards,
Blue, Blue
In SQL the CASE statement can do similar logic:
Proc sql;
create table mydata as
select distinct a.member_ID
,case
when a.member_ID in ('k') then 'Health plan v'
else ''
end as tempbucket
from tablec a;
quit;
Thanks for the response.
Let me try it tomorrow and I will get back to you:
Does this add a new variable? Or test different cases? Anyway, case statement can solve my situation.
If it is not "k only" it is "k" or "n", then what happens? I mean to use "or" with "in".
Can we bring our new variable after the word "case"?
Proc sql; create table mydata as select distinct a.member_ID ,case when a.member_ID in ('k') then 'Health plan v' else '' end as tempbucket from tablec a; quit;
Regards,
Blue, Blue
Please read the documentation and try running the code. If it is still not clear then ask further questions.
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.