Date: Tue, 29 Aug 2006 16:38:44 -0400
Reply-To: Xu Libin <Libin.Xu@IRS.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Xu Libin <Libin.Xu@IRS.GOV>
Subject: Re: I am puzzled by the error message for the array?
In-Reply-To: A<BAY123-F39966CD35EFC81575BEBFEDE390@phx.gbl>
Content-Type: text/plain; charset="US-ASCII"
Toby,
Thank you so much for explaining the error message! Now I am clear
why this happens. I appreciate very much your taking the time to share
your experience with a novice array programmer.
Libin
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
toby dunn
Sent: Tuesday, August 29, 2006 4:13 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: I am puzzled by the error message for the array?
Xu ,
Odds are you created &Q1_Len some other way or with some other dataset,
so
it already has a value. Thus when you get to your put statement it is
in
the macro symbol table and has a value.
Where as Q10_Len has never been defined anywhere other than in yoru SQL
statement. Since no Rows were selected it does not create in the macro
symbol table.
Try this:
Proc SQL NoPrint ;
Select Length Into : Q10_Len
From Dictionary.Columns
Where LibName = 'WORK'
And MemName = 'TAB1'
And UpCase( Name ) = 'Q10' ;
Quit ;
%Put >>>&Q10_Len.<<< ;
If this works it was the problem that your variable names were
capitalized
in the Column's table. If it still selects no rows then Q10 is not in
the
table to start with and you need to look further up the code chain to
see
where everything went wrong at.
Toby Dunn
When everything is coming at you all at once, your in the wrong lane.
A truly happy person is someone who can smile and enjoy the scenery on a
detour.
From: Xu Libin <Libin.Xu@IRS.GOV>
Reply-To: Xu Libin <Libin.Xu@IRS.GOV>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: I am puzzled by the error message for the array?
Date: Tue, 29 Aug 2006 16:02:02 -0400
Toby,
I ran the sql section and the log says that q10_len is not resolved. But
what I don't understand is why the same syntax ended up with two
different results. Thanks for your advice.
Libin
844 proc sql;
845 select length into :q10_len
846 from dictionary.columns
847 where libname='WORK' and memname='TAB1' and name='q10';
NOTE: No rows were selected.
848 %put &q10_len;
WARNING: Apparent symbolic reference Q10_LEN not resolved.
&q10_len
849 quit;
850 proc sql;
851 select length into :q1_len
852 from dictionary.columns
853 where libname='WORK' and memname='TAB1' and name='q1';
NOTE: No rows were selected.
854 %put &q1_len;
6
855 quit;
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
toby dunn
Sent: Tuesday, August 29, 2006 3:35 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: I am puzzled by the error message for the array?
XU ,
Your macro variable q10_len was never created. GO back and look at your
SQL
code for that example and start debugging it from there.
Toby Dunn
When everything is coming at you all at once, your in the wrong lane.
A truly happy person is someone who can smile and enjoy the scenery on a
detour.
From: Xu Libin <Libin.Xu@IRS.GOV>
Reply-To: Xu Libin <Libin.Xu@IRS.GOV>
To: SAS-L@LISTSERV.UGA.EDU
Subject: I am puzzled by the error message for the array?
Date: Tue, 29 Aug 2006 15:29:12 -0400
Can any SAS array expert tell me why the first program works perfectly
but the second program gave me an error message? The only difference
between the two is q1 becomes q10. Thanks.
I also enclose the error message at the end.
Libin
Program 1:
proc sql;
select length into : q1_len
from dictionary.columns
where libname='WORK' and memname='TAB1' and name='q1';
quit;
data tabQ1 ( Drop = I );
set tab1;
Array q1_(&q1_len) ;
Do I = 1 to &q1_len;
If Not (Verify(Strip(Put(I , 8. -L)) , q1)) Then Do ;
q1_(I) = 1 ;
End ;
Else Do ;
q1_(I) = 0 ;
End;
End;
Run;
Program 2:
proc sql;
select length into : q10_len
from dictionary.columns
where libname='WORK' and memname='TAB1' and name='q10';
quit;
data tabQ10 ( Drop = I );
set tab1;
Array q10_(&q10_len) ;
Do I = 1 to &q10_len;
If Not (Verify(Strip(Put(I , 8. -L)) , q10)) Then Do ;
q10_(I) = 1 ;
End ;
Else Do ;
q10_(I) = 0 ;
End;
End;
Run;
Error message:
786 data tabQ10 ( Drop = I );
787 set tab1;
788 Array q10_(&q10_len) ;
-
22
-------
202
WARNING: Apparent symbolic reference Q10_LEN not resolved.
ERROR 22-322: Syntax error, expecting one of the following: a name,
an integer constant, *.
ERROR 202-322: The option or parameter is not recognized and will be
ignored.
789 Do I = 1 to &q10_len;
-
22
WARNING: Apparent symbolic reference Q10_LEN not resolved.
ERROR 22-322: Syntax error, expecting one of the following: a name,
a quoted string, a numeric constant, a datetime
constant,
a missing value, INPUT, PUT.
790 If Not (Verify(Strip(Put(I , 8. -L)) , q10)) Then Do ;
791 q10_(I) = 1 ;
792 End ;
793 Else Do ;
794 q10_(I) = 0 ;
795 End;
796 End;
797 Run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TABQ10 may be incomplete. When this step was
stopped there were 0 observations and 89 variables.
WARNING: Data set WORK.TABQ10 was not replaced because this step was
stopped.