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

I have two datasets.

DATASET2 is a database.

I want to find only the info about missing records from DATASET2(with var1 the DATASET2 might have multiple recorde)

They have var1 in common

How can i use the CNTLIN to acheive this????

Is there any other easier??

DATASET1                             DATASET2
var1    var2                              var1  ....................

101     a

102   b

103    missing

104   missing

105   missing

106   missing

107  f

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

For the sake of demonstration ...

/* Create a CNTLIN dataset as a SAS view with the required variable names */

data missFormat / view=missFormat;
set dataset2;
FMTNAME = "missFormat";
START = var1;
LABEL = strip(var2);
run;

/* Create the format */

proc format cntlin=missFormat; run;

/* Use the format to subset data, for example */

data dataset3;
set dataset1(where=(put(var1,missFormat.)="missing"));
run;

Not that I would ever do this...

PG

PG

View solution in original post

4 REPLIES 4
DBailey
Lapis Lazuli | Level 10

I'm not sure how proc format applies or that I understand your question...but generally you can check for the existence of a record in a different table several ways.  One is:

Proc sql;

create table want as

select

     t1.*

from

     dataset1 t1

     left outer join dataset2 t2

          on t1.var1=t2.var1

where

     t2.var1 is null;

quit;

PGStats
Opal | Level 21

How about:

proc sql;

create table missing as

select * from dataset2

where var1 in (select var1 from dataset1 where upcase(var2)="MISSING");

quit;

PG

PG
robertrao
Quartz | Level 8

Hi ,

It was vwery helpful.Thanks for the replies...Could you also help me with creating CNTLIN...I am in the process of learning

Regards

PGStats
Opal | Level 21

For the sake of demonstration ...

/* Create a CNTLIN dataset as a SAS view with the required variable names */

data missFormat / view=missFormat;
set dataset2;
FMTNAME = "missFormat";
START = var1;
LABEL = strip(var2);
run;

/* Create the format */

proc format cntlin=missFormat; run;

/* Use the format to subset data, for example */

data dataset3;
set dataset1(where=(put(var1,missFormat.)="missing"));
run;

Not that I would ever do this...

PG

PG

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1137 views
  • 6 likes
  • 3 in conversation