SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
POOJA_J
Obsidian | Level 7

While practicing on SAS academics I daily ran the below code:

%let path=~/EMC1V2_Macro;

libname mc1 "&path/data";

 

Then created following macro and saved in the AUTOCALL library to use this macro again.

%macro propcase(text);
%sysfunc(propcase(&text))
%mend propcase;

 

Next time when I login into SAS, and run the LIBNAME statement with below code it runs smoothly. Calling the macro PROPCASE works here.

options sasautos=("/home/u62036390/EMC1V2_Macro/autocall",sasautos);

 

Other situation when I login into SAS, I just need my libraries so I run the LIBNAME statement without OPTIONS SASAUTOS. But after a while I run this OPTIONS SASAUTOS and then if I call the macro it doesn't resolve.

 

To me this appears as if the OPTIONS SASAUTOS is working only when I run with the LIBNAME statement. But in Advanced programming performance based exam, we don't need to define libraires. This is automatically done when we start the exam. 

Suppose in the exam, I want to built my AUTOCALL library so I can use the macros saved in the exam. But here  as the libraries are not needed to be defined and as per my understanding if the OPTIONS SASAUTOS is working only with the LIBNAME statement it will give me a error that the macro was not found. Please correct if I misunderstood the concept and also guide how this will work in the exam specially. 

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

I'm not familiar with the SAS Exam environment.

 

But there is no relationship between using the OPTIONS statement to update the SAS autocall library search path, and using a LIBNAME statement.  I would work on debugging this problem further.

 

One possibility is if you accidentally call %PROPCASE once before you have updated the autocall search path, and then you update the search path, and then try again to call %PROPCASE, it will fail.  Because by default SAS will only search the autocall library for the definition of %PROPCASE once per session.  To change that behavior, you can set system option MRECALL.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.

View solution in original post

5 REPLIES 5
Quentin
Super User

I'm not familiar with the SAS Exam environment.

 

But there is no relationship between using the OPTIONS statement to update the SAS autocall library search path, and using a LIBNAME statement.  I would work on debugging this problem further.

 

One possibility is if you accidentally call %PROPCASE once before you have updated the autocall search path, and then you update the search path, and then try again to call %PROPCASE, it will fail.  Because by default SAS will only search the autocall library for the definition of %PROPCASE once per session.  To change that behavior, you can set system option MRECALL.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
POOJA_J
Obsidian | Level 7
Got it. I created the %propcase macro and to check it doesn't have any errors I called it. Then saved in the AUTOCALL library and then used the OPTIONS SASAUTOS. So when I'm trying to call it again it gives error.
Quentin
Super User

Hi,

 

Actually this:

@POOJA_J wrote:
Got it. I created the %propcase macro and to check it doesn't have any errors I called it. Then saved in the AUTOCALL library and then used the OPTIONS SASAUTOS. So when I'm trying to call it again it gives error.

Should not give an error.  If you manually compile the %propcase macro and successfully call it, then add it to the autocall library, the next time you call the %propocase macro in the same session it should still work.  Because the macro has already been compiled, it will not actually read from the autocall library.

 

The situation I was describing was slightly different.  Suppose you start a SAS session and call %propcase and the macro call fails, because it has not been compiled and does not exist in an autocall library. Then you update the SASAUTOS option.  Then you try to call %propcase again.  In that case the call to %propcase will still fail, even if propcase.sas is an autocall library.  Basically SAS remembers that it has already looked in the autocall library once for the definition of propcase, so by default it will not look a second time.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
POOJA_J
Obsidian | Level 7
Got it. Thanks for this detailed explanation. I tried the whole thing again as per your explanation and now it's working. Thanks a ton.
PaigeMiller
Diamond | Level 26

Whenever (that's 100% of the time, NO EXCEPTIONS), when you get an error in the log, show us the ENTIRE log. We need to see the ENTIRE log (down to the errors), not just a portion of the log.

 

Please copy the log as text and paste it into the window the appears when you click on the </> icon, PLEASE DO NOT SKIP THIS STEP.

PaigeMiller_0-1663012019648.png

--
Paige Miller

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1740 views
  • 7 likes
  • 3 in conversation