BookmarkSubscribeRSS Feed
astha8882000
Obsidian | Level 7

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?

4 REPLIES 4
novinosrin
Tourmaline | Level 20

Why is there a period added while referencing it?

 

Test the same code without the period as suffix

Astounding
PROC Star

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

 

 

astha8882000
Obsidian | Level 7

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

Astounding
PROC Star

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1335 views
  • 3 likes
  • 3 in conversation