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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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