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 (September 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 4 Sep 2007 21:41:21 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject:      Re: Proc SQL to Array Macro-Atuoo Inserting Spaces

On Tue, 4 Sep 2007 15:07:28 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote:

>Two quick solutions: > > > >select %SysFunc( Compress( Input( count(name) , 8. ) ) ) into: varnum >from contents >Wheer Type = 2 ;

I think Toby meant PUT, not INPUT.

Also, the %SYSFUNC does not belong. It compresses code, at compile time, so

" Input( count(name) , 8. "

becomes

"Input(count(name),8."

and does not affect the content of &VARNUM. >> >Toby Dunn > > > >From: anderson115@GMAIL.COM >Reply-To: anderson115@GMAIL.COM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Proc SQL to Array Macro-Atuoo Inserting Spaces >Date: Tue, 4 Sep 2007 08:00:10 -0700 > >I'm trying to create a numbered list of macro variables using proc sql >with the highest number in the variable list as the maximum number of >records: > >proc sql; > >select count(name) into: varnum from contents; > >select name into: char1 - char&varnum from contents >where type = 2; > >quit; > >What I would like is a numbered list of macro variables that represent >all character variable names from the contents table. > >When proc sql attempts to create the CHAR&VARNUM variable there is a >space introduced between "CHAR" and the sequential numeric suffix.

Actually, the problem arises when &VARNUM is *created*, not when it is concatenated to "CHAR".

Also, since the WHERE clause is not coded in the first statement, &VARNUM may receive a value larger than intended. That's harmless though.

Why not use DATA NULL's suggestion? Skip the first statement and just use a really big integer for the upper bound. PROC SQL will do the right thing.

But why create all of these macro variables? There's probably a better way to complete the task.

>How can I avoid this? > >Thank You, >Aaron


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