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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.