DATA Step, Macro, Functions and more

Macro variable not resolving ??

Reply
Contributor
Posts: 27

Macro variable not resolving ??

I am writing a code in SAS.

I have preexisting Macro variables in my envt which resolve
to something. How do I know where they are defined in unix solaris? Any
particular command I can use to see where the envt variables are defined in a
common location?

If at all I need to create a new macro var  &xyz  where do I create it? And how to write it?

I used   %let XYZ=%sysget(XYZ);

%put XYZ=&XYZ;

I see the following error in the log: SYMBOLGEN:  Macro variable XYZ resolves to

But I do not see anything after resolves to – meaning it is not
resolved. Any suggestions appreciated.

I am not sure if this is an environmental specific question, but
thought I’d ask anyways.. Thanks.

Super User
Posts: 5,424

Re: Macro variable not resolving ??

Posted in reply to swathi123

A bit confused about your requirement.

Do you wish to use an existing environment variable? If so, contact the responsible party for defining such variables, whoever that can be.

Or do want to how to define a macro variable as such? Macro variables can be defined anywhere in SAS programs, best place depends on your situation. So, please describe in more detail what kind of macro variable yo9uo need, and do you intend to use it.

Data never sleeps
Contributor
Posts: 27

Re: Macro variable not resolving ??

Using existing variable is what i need. How do i define them? where do i locate them?

in order for me to write a new envtl variable i need to first understand the existing envtl variables right?

Hope I was clear

Super User
Posts: 11,343

Re: Macro variable not resolving ??

Posted in reply to swathi123

If you are talking about reading environment variables, SAS generally isn't involved with setting them, they mostly come from the operating system. So where they are set dependins on your OS and environment. The exceptions would be those created using SET in the SAS configuration file.

I haven't found anything that allows SAS to send values to environment variables unless you want to think of RSUBMIT login information for database access as such.

If the environment variable XYZ in your example wasn't set by the OS then you wouldn't get anything.

Contributor
Posts: 39

Re: Macro variable not resolving ??

Posted in reply to swathi123

I am assuming that you have a macro somewhere in a directory. Just call the macro using %include statement. Eg,

filename test1 '/home/o568484/test.sas'; /*directory for the location of the macro in unix */

%include test1;

If test.sas contains %let XYZ=14


When you include

%put &XYZ = ;


You should not get the error.

I hope this would help.

Super User
Super User
Posts: 7,039

Re: Macro variable not resolving ??

Posted in reply to swathi123

If you want to see what macro variables are defined currently then use %PUT _ALL_; or %PUT _GLOBAL_;

If you want to see what ENVIRONMENT variables were defined before SAS started then you will need to use operating system commands.  You could try this simple data step which should work on Unix or Windows.

data _null_;

  infile 'set' pipe ;

  input;

  put _infile_;

run;

Ask a Question
Discussion stats
  • 5 replies
  • 217 views
  • 0 likes
  • 5 in conversation