f



Re: How to filter sas data sets into separate sas data s ets

I think that both Ron's (as he mentioned) and Richard solutions require that
VAR1 is in both datasets.

But from the original post, it seemed to me that VAR1 is only in data set 1,
and it must be matched to 1 of 3 variables in data set 2 (NODE1, NODE2 or
NODE3) to be output to the NEWLIST data set.  For this reason, I think a
format is one possible approach.

Maybe the original poster can clarify this point.  Thanks.


Jack Clark
Research Analyst
Center for Health Program Development and Management
University of Maryland, Baltimore County


-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Fehd,
Ronald J. (CDC/CCHIS/NCPHI)
Sent: Monday, April 02, 2007 11:21 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: How to filter sas data sets into separate sas data sets

you cannot do this as described without a common link
here, your Var1

Note: both data sets must be sorted by Var1

Data Newlist (KEEP=node1 node2 node3 ... var15)
     Otherds (Keep=node1 node2 node3 .... var15) ;

do until(EndoFile);

Set SASDS1
    SASDS2 end = EndoFile;
by  Var1;

*consider: if Var1 in (Node1 Node2 Node3);

If    Node1 = VAR1
   or Node2 = VAR1
   or Node3 = Var1
   then Output Newlist ;
Else    Output Otherds ;

end;
stop;

Undoubtedly the HashHeads will propose a lookup table

but the above is what you are trying to do.

Ron Fehd  the macro maven  CDC Atlanta GA USA RJF2 at cdc dot gov

> From: starsoul@mindspring.com
> Listers,
>
> This is my failing point in coding SAS.  The use of 2
> separate SAS data sets to create a third.
>
> I can do this in a program with nested Do loops.  But with
> SAS it is just different enough I seem to be unable to see
> the coding technique.
>
> Problem:
>
> Sas Data set 1 contains 1 variable and 1000 obs.
> Sas Data set 2 contains 15 variables and 500000 obs.
>
> I need to filter off the data in Sas data set 2 based on Sas
> data set 1
>
> Node1, Node2 and Node3 must match VAR1 exactly.  I have all
> the code I need to do this except for splitting the data into
> a separate SAS data set (NEWLISTS).
>
>
> Psuedo code:
>
> Sas Data set 1:  Var1 Length 7 Char
> Sas Data set 2:  Node1 Length 1-8 Char   Node2 Length 1-8
> Char  Node3 Length 1-8 Char
>
>
>
> Data Newlist (KEEP=node1 node2 node3 ... var15)
>      Otherds (Keep=node1 node2 node3 .... var15) ;
>
> Set SASDS1 ;   *Contains 1 var 1000 obs   ;
> Set SASDS2 ;   *Contains 15 vars and 500,000 obs  ;
>
>
> If Node1 = VAR1 or Node2 = VAR1 or Node3 = Var1 then Output
> Newlist ; Else Output Otherds ;
>
>
> I have tried putting in two SET statements, but I seem to
> reduce the information dramatically.  I have been reviewing
> the coding examples on the SAS Wesbsite as well as in the
> archives.  I am just so crunched for time that I must lean on
> you for assistance.
>
> I know this should be easy, I am just not seeing.
0
JClark1 (431)
4/2/2007 3:54:59 PM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
877 Views

Similar Articles

[PageSpeed] 37

Reply: