BookmarkSubscribeRSS Feed
rakeshvvv
Quartz | Level 8

I Have to run to edit check query on table having collumns customerid, product and orderno.

ordernumber has values(1-5). not all ordernumbers(1-5) are valid for every product.If the same product has all the values from 1-5 , then it is discrepancy. I need to pull out those records with discrepany.

ID   product orderno

001 apple      1

001 apple      2

001 apple      3

001 apple      4

001 apple      5

002 orange    1

002 orange    3

003 banana   1

003 banana   2

004 berry      1

004 berry       2

In the above table id(001) with product apple is discrepany because it has all the values 1-5. i need to pull out those reocord from the table.

Thansk in advance

Rakesh

2 REPLIES 2
RichardinOz
Quartz | Level 8

Something like this (not tested)

Proc sql ;

     create table want as

          select a.*

          from have a

               , (Select product

                    ,  count (distinct order) as tot

                    from have

                 )     b

          where a.product = b.product

               and b.tot = 5

     ;

quit ;


Richard

rakeshvvv
Quartz | Level 8

Thanks Richard......


sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 2 replies
  • 390 views
  • 1 like
  • 2 in conversation