LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2003, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 22 May 2003 13:53:01 -0400
Reply-To:     "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Subject:      Re: _N_ in PROC SQL
Comments: To: Jeff Morison <jmt_mtf@YAHOO.COM>
Content-Type: text/plain; charset="iso-8859-1"

You can use the undocumented monotonic() function to simulate _n_. Sample usage:

proc sql ; select monotonic() as rownum, * from <your data> ; quit ;

If you are doing any GROUP BY processing in your SQL this may not work.

A better alternative is to use a datastep view.

data yourview / view = yourview ; set yourdata ; rownum = _n_ ; run ; __________________________ Venky Chakravarthy E-mail:

-----Original Message----- From: Jeff Morison [mailto:jmt_mtf@YAHOO.COM] Sent: Thursday, May 22, 2003 1:29 PM To: SAS-L@LISTSERV.UGA.EDU Subject: _N_ in PROC SQL

Thanks to all who responded to my earlier qn.

Here is another one.

I need to create a variable with the value of _N_ in PROC SQL?, is there a way to do this?.

It gives me this ERROR message

ERROR: The following columns were not found in the contributing tables: _N_. 1023 QUIT;

TIA, Jeff

__________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo.

LEGAL NOTICE Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.

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