BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GN0001
Barite | Level 11

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?

 

 

 

Blue Blue
1 ACCEPTED SOLUTION

Accepted Solutions
GN0001
Barite | Level 11

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

Blue Blue

View solution in original post

4 REPLIES 4
SASKiwi
PROC Star

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;
GN0001
Barite | Level 11

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

Blue Blue
SASKiwi
PROC Star

Please read the documentation and try running the code. If it is still not clear then ask further questions.

GN0001
Barite | Level 11
This response saved me. Thanks 🙏
Blue blue
Blue Blue

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1491 views
  • 1 like
  • 2 in conversation