Date: Sat, 10 May 2008 16:36:46 -0700
Reply-To: "email@example.com" <dc353@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "firstname.lastname@example.org" <dc353@HOTMAIL.COM>
Subject: Re: selecting observations
Content-Type: text/plain; charset=ISO-8859-1
On May 10, 6:16 pm, hs AT dc-sug DOT org ("Howard Schreier)" wrote:
> On Sat, 10 May 2008 15:03:34 -0700, dc...@hotmail.com <dc...@HOTMAIL.COM> wrote:
> >On May 10, 11:34 am, "dc...@hotmail.com" <dc...@hotmail.com> wrote:
> >> On May 10, 11:23 am, "dc...@hotmail.com" <dc...@hotmail.com> wrote:
> >> > Hi,
> >> > I have two datasets. The first contains about 1000 observations with
> >> > two vars ID and WGHT, the second contains over a million records with
> >> > with DATE ID and FAC1-FAC25. I need to create a third dataset with
> >> > Where DATE = 200701
> >> > DATE ID WGHT FAC1-FAC25
> >> > and a 4th dataset with any ID's from the first dataset that couldn't
> >> > be found in the second dataset-
> >> > I'm not sure if this should be done with a merge or proc sql. Any
> >> > suggestions would be appreciated. (SAS NEWBE)
> >> Does the following make sense?
> >> proc sql;
> >> select ID into :refids separated by ' ' from FIRST;
> >> %put &refids;
> >> create table THIRD as
> >> select *
> >> from SECOND
> >> where refid in (&refids)
> >> and DATE = 200701;
> >> quit;
> >> then do a merge between the FIRST and THIRD and then pull out the
> >> missing obs into FOURTH. Is there a more direct/simpler/better way of
> >> doing this?
> >I ran the following code and it's not working::
> >148 proc sql;
> >150 select symbol into :refids separated by ' ' from cdrive.port;
> >152 %put &refids;
> >ABT BAX BMY AAPL IBM
> >154 create table cdrive.THIRD as
> >155 select *
> >156 from cdrive.sp2
> >157 where symbol in (&refids)
> >NOTE: Line generated by the macro variable "REFIDS".
> >1 ABT BAX BMY AAPL IBM
> > ---
> > 22
> > 76
> >ERROR 22-322: Syntax error, expecting one of the following: a quoted
> >string, a numeric constant,
> > a datetime constant, a missing value, (, -, SELECT.
> >ERROR 76-322: Syntax error, statement will be ignored.
> >158 ;
> >160 quit;
> >NOTE: The SAS System stopped processing this step because of errors.
> >NOTE: PROCEDURE SQL used:
> > real time 0.01 seconds
> > cpu time 0.01 seconds
> >Does SYMBOL need to be a numeric for this to work? There must be a
> >way to do this as a character. Any help would be appreciated.
> The ERROR message provides such help.
Great, I just don't understand what it is trying to tell me. I've
been searching on SAS.com for some clue to the error message.