DATA Step, Macro, Functions and more

Difference between &A and &A.

Reply
Occasional Contributor
Posts: 6

Difference between &A and &A.

I'm looking at a piece of code given below, this is just a small part of a really big project. But I'm unable to understand a concept here:

 

Proc sql noprint;

      Select max(count) into:A

            From ABC;

quit;

 

DATA _NULL_;

      IF &A. < 1 THEN

            DO;

            [some code]

END;

 

Here, A is a macro variable as provided in the proc sql statements, then instead of referencing it as &A in the data step, why is this being referred to as &A.. Why is there a period added while referencing it?

PROC Star
Posts: 1,296

Re: Difference between &A and &A.

Posted in reply to astha8882000

Why is there a period added while referencing it?

 

Test the same code without the period as suffix

Super User
Posts: 6,532

Re: Difference between &A and &A.

Posted in reply to astha8882000

The period is optional when referring to a macro variable.  It doesn't matter if  you use it here or not.

 

It comes in handy when the name of the macro variable is ambiguous.  For example:

 

&ABC

 

Is this the macro variable &A followed by the letters "BC"  or is it the macro variable &ABC?  For the macro variable &A followed by the letters "BC" you would clarify that by using:

&A.BC

 

 

Occasional Contributor
Posts: 6

Re: Difference between &A and &A.

Posted in reply to Astounding

ABC is a table and A is just a variable that  is obtaining some value from that table.

Super User
Posts: 6,532

Re: Difference between &A and &A.

Posted in reply to astha8882000

OK, I think you need a few examples to clarify then.  Try running this code:

 

%let a=1;

%let ab=2;

%let abc=3;

 

%put abc;

%put &abc;

%put &abc.;

%put &a.bc;

%put &ab.c;

Ask a Question
Discussion stats
  • 4 replies
  • 88 views
  • 3 likes
  • 3 in conversation