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

Hi Everyone,

  I have the Data in the below structure, I just want to check A variable numbers in B variable List. If the A variable Number not found in B variable I need that non matching record in output.

SnoAB
111,2,3,4,5,6,7,8,9,10
221,2,3,4,5,6,7,8,9,10
341,2,3,4,5,6,7,8,9,10
451,2,3,4,5,6,7,8,9,10
51,21,2,3,4,5,6,7,8,9,10
62,61,2,3,4,5,6,7,8,9,10
73,81,2,3,4,5,6,7,8,9,10
80,111,2,3,4,5,6,7,8,9,10
912,8,181,2,3,4,5,6,7,8,9,10

Note;- Both variables in Character.


Here i am supposed to get 8th and 9th Observation in output.Please help me on this.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

A simple datastep approach :

data have;

length A B $32;

input Sno A B;

datalines;

1 1 1,2,3,4,5,6,7,8,9,10

2 2 1,2,3,4,5,6,7,8,9,10

3 4 1,2,3,4,5,6,7,8,9,10

4 5 1,2,3,4,5,6,7,8,9,10

5 1,2 1,2,3,4,5,6,7,8,9,10

6 2,6 1,2,3,4,5,6,7,8,9,10

7 3,8 1,2,3,4,5,6,7,8,9,10

8 0,11 1,2,3,4,5,6,7,8,9,10

9 12,8,18 1,2,3,4,5,6,7,8,9,10

;

data absent;

length missNumber $12;

set have;

do i = 1 to countw(A);

    missNumber = scan(A, i, ",");

    if findw(B, missNumber, ",", "t") = 0 then do;

        output;

        leave; /* Remove this statement to get all missing numbers */

        end;

    end;

keep Sno missNumber;

run;

proc print data=absent noobs; run;

PG

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

A simple datastep approach :

data have;

length A B $32;

input Sno A B;

datalines;

1 1 1,2,3,4,5,6,7,8,9,10

2 2 1,2,3,4,5,6,7,8,9,10

3 4 1,2,3,4,5,6,7,8,9,10

4 5 1,2,3,4,5,6,7,8,9,10

5 1,2 1,2,3,4,5,6,7,8,9,10

6 2,6 1,2,3,4,5,6,7,8,9,10

7 3,8 1,2,3,4,5,6,7,8,9,10

8 0,11 1,2,3,4,5,6,7,8,9,10

9 12,8,18 1,2,3,4,5,6,7,8,9,10

;

data absent;

length missNumber $12;

set have;

do i = 1 to countw(A);

    missNumber = scan(A, i, ",");

    if findw(B, missNumber, ",", "t") = 0 then do;

        output;

        leave; /* Remove this statement to get all missing numbers */

        end;

    end;

keep Sno missNumber;

run;

proc print data=absent noobs; run;

PG

PG
Daya87
Calcite | Level 5

Thanks a lot, It's working Fine.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 429 views
  • 0 likes
  • 2 in conversation