Date: Mon, 11 May 2009 13:57:10 -0400
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: how to reference _null_ variables in proc SQL
In a data _null_ step you don't create any variable, nor observations! In
that SQL step, you use a macro variable &process_date. Where does that
come from? I cannot see it anywhere in your code.
If you want the result of substr(put(today()-1,yymmdd6.),2,5) you must
bring that in the macro variable, eg with
call symput("process_date",substr(put(today()-1,yymmdd6.),2,5));
The variable process_date you don't need and it has nothing to do with the
macro variable!
You also don't need a data _null_ step:
%let process_date=%sysfunc(substr(%sysfunc(putn(%eval(%sysfunc(today())-
1),yymmdd6.)),2,5));
Gerhard
On Mon, 11 May 2009 10:29:25 -0700, Paul Lambson <paullambson@GMAIL.COM>
wrote:
>I am having trouble referencing variables that i have created in a
>null data set within a proc SQL step.
>
>data _null_;
>length process_date $5;
>process_date=substr(put(today()-1,yymmdd6.),2,5);
>put (_all_)(=);
>run;
>
>
>then within the PROC SQL step I reference the variable like this
>
>AND ProcessDate= &process_date
>
>and it inputs the formula "substr(put(today()-1,yymmdd6.),2,5)" rather
>than the result "90510" this causes the step to stop have an error
>because the function "today()" is not recognized.
>
>what syntax should I use to return the product of the formula into the
>proc SQL step rather than the formula itself?
>
>Thanks,
>Paul
|