Go Back   Rhinocerus > Newsgroup > Newsgroup comp.soft-sys.sas

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 08-07-2012, 01:55 PM
chadmcrawford@gmail.com
Guest
 
Posts: n/a
Default % Let statement

Rather new to sas and am trying to use a %let statement.

I want to make use a % let statement for 0806, so I only have to change that number once in my code. You see it 4 times used below. I don't have a macro setup in this code.


/*join call*/
proc sql;
create table spd.acq_data_0806_2 as
(select a.*, b.*
from spd.acq_data_0806 as a
quit;

/*flag state, and add var*/
data spd.acq_data_0806_3;
set spd.acq_data_0806_2;

What all do I need to include in order use a %let statment similar to %let day=0806.
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 08-07-2012, 02:42 PM
Al
Guest
 
Posts: n/a
Default Re: % Let statement

On Tuesday, August 7, 2012 8:55:11 AM UTC-5, (unknown) wrote:
> Rather new to sas and am trying to use a %let statement.
>
>
>
> I want to make use a % let statement for 0806, so I only have to change that number once in my code. You see it 4 times used below. I don't have a macro setup in this code.
>
>
>
>
>
> /*join call*/
>
> proc sql;
>
> create table spd.acq_data_0806_2 as
>
> (select a.*, b.*
>
> from spd.acq_data_0806 as a
>
> quit;
>
>
>
> /*flag state, and add var*/
>
> data spd.acq_data_0806_3;
>
> set spd.acq_data_0806_2;
>
>
>
> What all do I need to include in order use a %let statment similar to %let day=0806.


asssign a macro variable day to the 0806 and use &day in the rest of the code. also, check the syntax of your sql code

%let day = 0806;
proc sql;
create table spd.acq_data_&day_2 as
(select a.*, b.*

from spd.acq_data_&day as a

quit;



/*flag state, and add var*/
data spd.acq_data_&day_3;
set spd.acq_data_&day_2;
run;

HTH
Al
Reply With Quote
  #3 (permalink)  
Old 08-07-2012, 02:52 PM
Al
Guest
 
Posts: n/a
Default Re: % Let statement

On Tuesday, August 7, 2012 8:55:11 AM UTC-5, (unknown) wrote:
> Rather new to sas and am trying to use a %let statement.
>
>
>
> I want to make use a % let statement for 0806, so I only have to change that number once in my code. You see it 4 times used below. I don't have a macro setup in this code.
>
>
>
>
>
> /*join call*/
>
> proc sql;
>
> create table spd.acq_data_0806_2 as
>
> (select a.*, b.*
>
> from spd.acq_data_0806 as a
>
> quit;
>
>
>
> /*flag state, and add var*/
>
> data spd.acq_data_0806_3;
>
> set spd.acq_data_0806_2;
>
>
>
> What all do I need to include in order use a %let statment similar to %let day=0806.


%let day = 0806;

> proc sql;
>
> create table spd.acq_data_&day_2 as
>
> (select a.*, b.*
>
> from spd.acq_data_&day as a
>
> quit;
>
>
>
> /*flag state, and add var*/
>
> data spd.acq_data_&day_3;
>
> set spd.acq_data_&day_2;

run;

also , check you sql code for syntax errors
HTH
Al
Reply With Quote
  #4 (permalink)  
Old 08-07-2012, 03:50 PM
chadmcrawford@gmail.com
Guest
 
Posts: n/a
Default Re: % Let statement

On Tuesday, August 7, 2012 10:42:44 AM UTC-4, Al wrote:
> On Tuesday, August 7, 2012 8:55:11 AM UTC-5, (unknown) wrote: > Rather new to sas and am trying to use a %let statement. > > > > I want to make use a % let statement for 0806, so I only have to change that number once in mycode. You see it 4 times used below. I don't have a macro setup in this code. > > > > > > /*join call*/ > > proc sql; > > create table spd.acq_data_0806_2 as > > (select a.*, b.* > > from spd.acq_data_0806 as a > > quit; > >> > /*flag state, and add var*/ > > data spd.acq_data_0806_3; > > set spd.acq_data_0806_2; > > > > What all do I need to include in order use a %let statment similar to %let day=0806. asssign a macro variable day to the 0806 and use &day in the rest of the code. also, check the syntax of your sqlcode %let day = 0806; proc sql; create table spd.acq_data_&day_2 as (select a.*, b.* from spd.acq_data_&day as a quit; /*flag state, and add var*/ data spd.acq_data_&day_3; set spd.acq_data_&day_2; run; HTH Al


So %macro macro1(day);

and then put a %mend at the end of my code. is that what you are referring too?
Reply With Quote
  #5 (permalink)  
Old 08-07-2012, 10:33 PM
Barry Schwarz
Guest
 
Posts: n/a
Default Re: % Let statement

On Tue, 7 Aug 2012 07:42:44 -0700 (PDT), Al <ali6058@gmail.com> wrote:

>On Tuesday, August 7, 2012 8:55:11 AM UTC-5, (unknown) wrote:
>> Rather new to sas and am trying to use a %let statement.
>>
>>
>>
>> I want to make use a % let statement for 0806, so I only have to change that number once in my code. You see it 4 times used below. I don't have a macro setup in this code.
>>
>>
>>
>>
>>
>> /*join call*/
>>
>> proc sql;
>>
>> create table spd.acq_data_0806_2 as
>>
>> (select a.*, b.*
>>
>> from spd.acq_data_0806 as a
>>
>> quit;
>>
>>
>>
>> /*flag state, and add var*/
>>
>> data spd.acq_data_0806_3;
>>
>> set spd.acq_data_0806_2;
>>
>>
>>
>> What all do I need to include in order use a %let statment similar to %let day=0806.

>
>asssign a macro variable day to the 0806 and use &day in the rest of the code. also, check the syntax of your sql code
>
>%let day = 0806;
>proc sql;
> create table spd.acq_data_&day_2 as


Doesn't that need to be &day._2?

> (select a.*, b.*
>
>from spd.acq_data_&day as a
>
> quit;
>
>
>
> /*flag state, and add var*/
>data spd.acq_data_&day_3;
>set spd.acq_data_&day_2;


Also for the two above.

>run;


--
Remove del for email
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 03:46 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.