Help using Base SAS procedures

PROC FORMAT

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,040
Accepted Solution

PROC FORMAT

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


Accepted Solutions
Solution
‎03-15-2013 05:00 PM
Respected Advisor
Posts: 4,660

Re: PROC FORMAT

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


All Replies
Super Contributor
Posts: 578

Re: PROC FORMAT

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;

Respected Advisor
Posts: 4,660

Re: PROC FORMAT

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
Super Contributor
Posts: 1,040

Re: PROC FORMAT

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

Solution
‎03-15-2013 05:00 PM
Respected Advisor
Posts: 4,660

Re: PROC FORMAT

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
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 232 views
  • 6 likes
  • 3 in conversation