Date: Mon, 22 Jun 2009 09:38:51 -0400
Reply-To: Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject: Re: Proc sql select :into and macro variables
On Sun, 21 Jun 2009 16:50:39 -0700, dc353@hotmail.com <dc353@HOTMAIL.COM>
wrote:
...
>could someone explain why the first case runs but the second case
>generates an error message?
...
>SECOND CASE
>944 proc sql noprint;
>945 select count(*) into :max_cnt
>946 from (select distinct d_date from fs.test_mm);
>947
>948
>949 select distinct d_date into :idx_n1-:idx_n&max_cnt
>950 from fs.test_mm;
>NOTE: Line generated by the macro variable "MAX_CNT".
>1 idx_n 109
> ---
> 22
> 76
>ERROR 22-322: Syntax error, expecting one of the following: ',', FROM,
>NOTRIM.
hi,
as joe says, the error message says it all. macro assignments with %let
statement trim the leading and trailing blanks. The elect ... into phrase
does not. It is not difficulty to trim leading blanks yourself. I also
noticed that the first query can be simplified. see below. hope this helps.
cheers,
chang
/* just to clean up */
%symdel age1 age2 age3 age4 age5 age6;
/* assign each distinct age into macro array, age */
proc sql noprint;
select count(distinct age) as nAges into :nAges
from sashelp.class;
select distinct age into :age1-:age%left(&nAges)
from sashelp.class;
quit;
%put age1=&age1 age2=&age2;
/* on log
age1=11 age2=12
*/
|