BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ImSpartacus
Fluorite | Level 6

I'm a peculiar situation where I appear to get different results from a particular macro if the macro is called first in the code versus if it's called later in the code (presumably after the macro has been called with other parameters). I would generally expect a macro to return the same results if giving identical parameters. 

 

I haven't been able to reproduce this "error" in a more controlled manner (hence the lack of test code), but my macro uses PROC LOGISTIC to create a model from a subset of my data, save the results (list of variables, etc) to a given "total" dataset, The intention is for the macro to be run several times to work on different subsets of the data and append the results to that same "total" dataset for later output. 

 

Any tips on troubleshooting this? 

 

I do sincerely apologize for the unorthodox question without proper test code, but I appreciate any suggestions/tips. 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Things to check - the scope of your macro variables. Are you accidentally setting/resetting something?

Or modifying your data at some point and then running your model? Are you using a model selection method?

View solution in original post

5 REPLIES 5
Reeza
Super User

Things to check - the scope of your macro variables. Are you accidentally setting/resetting something?

Or modifying your data at some point and then running your model? Are you using a model selection method?

ImSpartacus
Fluorite | Level 6
Thanks for your thoughts.

It turned out that I WASN'T resetting a particular dataset of potential regression variables that was being appended. So everything worked, but the forward selection had "too many" variables to pick from in the macro calls that ran later on in the program.

I appreciate the feedback from everyone and I genuinely wish I could pick you all!
Astounding
PROC Star

When you say "several subsets" of the data, I'm picturing randomly selected subsets.  That could automatically make the results slightly different each time.

 

Even if you are controlling the seed for the random selector, the data set may be different.  For example, it may be sorted differently later in the program, causing the random selection to choose a different sample (even when the seed has not changed).

ImSpartacus
Fluorite | Level 6

In this particular situation, I'm using a relatively simple "filtering" method, but as a side note, I do use have a similar macro that does randomly subset data, and I didn't know about the effect of sorting on random selection (despite using the same seed). I'll have to remember that!

Thank you very much for your thoughts!

Kurt_Bremser
Super User

Hidden side effect. One of your macro variables you assume to be local might be global. Or a dataset that you assume to he static is actually changed.

Without code, and data to test it against, we can only guess.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 1540 views
  • 3 likes
  • 4 in conversation