LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 2010, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Apr 2010 19:02:21 -0400
Reply-To:     msz03@albany.edu
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mike Zdeb <msz03@ALBANY.EDU>
Subject:      Re: Merge and test which data has missing without knowing the
              dataset              name?
Content-Type: text/plain;charset=iso-8859-1

hi ... here's one possibility use an intermediate data step that looks at your macro variable &DSLIST and creates some code used in the MERGE

I suppose that you could also use the same approach with CALL EXECUTE or a data step that writes the entire MERGE then use %INCLUDE

data a; set sashelp.class; where ranuni(0) le .3; run;

data b; set sashelp.class; where ranuni(0) le .6; run;

data c; set sashelp.class; where ranuni(0) le .9; run;

* works with any combination of a, b, and c; %let dslist=a b c;

data _null_; length stuff1 stuff2 $200; dsets = "&dslist"; do j=1 by 1 while(scan(dsets,j) ne ''); stuff1 = catt(stuff1,scan(dsets,j),"(in=d",j,")"); stuff2 = catt(stuff2,"d",j,"="); end; j=j-1; call symputx('stuff1',stuff1); call symputx('stuff2',stuff2); call symputx('stuff3',j); run;

data all; merge &stuff1; by name; if sum(of d:) ne &stuff3 then put &stuff2; run;

-- Mike Zdeb U@Albany School of Public Health One University Place (Room 119) Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

> Hi there, > > Assume that I have a macro var that holds a list of dataset names. I then > use it for a merge: > > data all; > merge &dslist; > by keys; > run; > > Now I need to know if any of the dataset has missing record. Usually I > can do something like this: > > data all; > merge a(in=a_) b(in=b_) c=(in=c_); > by keys; > if not (a_ and b_ and c_) then put a_= b_= c_=; > run; > > From the log, I can tell which dataset has missing records. > > But for a macro var &dslist, I will not know how many datasets are > there, let alone write a if statement. So, easiy way to tell which > data has missing record? > > I probably can use meta data to construct a dslist with in= in it, > I'm looking for easier way. > > Thanks > > Ya >


Back to: Top of message | Previous page | Main SAS-L page