BookmarkSubscribeRSS Feed
SASdevAnneMarie
Barite | Level 11

Hello Experts,

 

I'm trying reorganise my data with proc sql : I count tne number of supports by NO_C, in case of 2 I would like to chose the Major if it's present :

input:

SASdevAnneMarie_0-1678745253650.png

Want:

SASdevAnneMarie_1-1678745306552.png

I'm wondering how I can use if prxmatch("m/MAJORATION/oi",lb_sup)> 0 condition in proc sql ?

 

Thank you !

1 REPLY 1
SASKiwi
PROC Star

This is a bit ugly but here is one way based on limited data. I don't think PRXMATCH is the best option here even if it does work in SQL (I haven't tried).

data have;
  input @1 NO_C $6.
        @8 lb_sup $10.
		@19 nb_supp 2.
		@21 top_supp_major 2.
		;
datalines;
JO2886 MINIMUM    2  0
JO2886 MAJORATION 2  1
B00405 MAJORATION 2  1
B00405 ACTIV1     2  0
B00867 ACTIV1     2  0
;
run;

proc sql;
  create table want as
  select *
  from have
  where top_supp_major = 1
  or (NO_C in 
      (select NO_C
       from have
       where top_supp_major = 0
       except
       select NO_C
       from have
       where top_supp_major = 1
      )
     );
quit;

 

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
  • 1 reply
  • 244 views
  • 0 likes
  • 2 in conversation