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

Greetings,

 

I'm running a program to impute some variables and for each variable I have a macro that is used by the core imputation program to define the range of values that are going to be attributed in the imputation procedure, like this:

 

 

%macro bound_secondary_profession;
    LB=1;
    UB=9;
%mend; 

The problem is that the imputed value of this particular variable must be different from the imputed value of the primary_profession variable and I must specify this restriction within this macro. So far I managed to come up with a solution for extreme values:

 

 

%macro bound_secondary_profession;
    LB=1;
    UB=9;
    IF primary_profession=1 then LB=2;
    IF primary_profession=9 then UB=8;
%mend;

But what if primary_profession is equal, let's say 2? How can I impose that the number 2 cannot be chosen, using LB and UB? 

 

This is more of a logic challenge rather than a SAS programming challenge, but I've been struggling with this issue for quite some time and I still can't find a way out.

 

Thank you very much for your support.

 

Best regards

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

It depends on how you're implementing it in the next portion. If you're using temporary arrays, you can just modify the array if needed or hardcode a condition in. 

 


@Luis_Martins wrote:

Greetings,

 

I'm running a program to impute some variables and for each variable I have a macro that is used by the core imputation program to define the range of values that are going to be attributed in the imputation procedure, like this:

 

 

%macro bound_secondary_profession;
    LB=1;
    UB=9;
%mend; 

The problem is that the imputed value of this particular variable must be different from the imputed value of the primary_profession variable and I must specify this restriction within this macro. So far I managed to come up with a solution for extreme values:

 

 

%macro bound_secondary_profession;
    LB=1;
    UB=9;
    IF primary_profession=1 then LB=2;
    IF primary_profession=9 then UB=8;
%mend;

But what if primary_profession is equal, let's say 2? How can I impose that the number 2 cannot be chosen, using LB and UB? 

 

This is more of a logic challenge rather than a SAS programming challenge, but I've been struggling with this issue for quite some time and I still can't find a way out.

 

Thank you very much for your support.

 

Best regards

 


 

View solution in original post

1 REPLY 1
Reeza
Super User

It depends on how you're implementing it in the next portion. If you're using temporary arrays, you can just modify the array if needed or hardcode a condition in. 

 


@Luis_Martins wrote:

Greetings,

 

I'm running a program to impute some variables and for each variable I have a macro that is used by the core imputation program to define the range of values that are going to be attributed in the imputation procedure, like this:

 

 

%macro bound_secondary_profession;
    LB=1;
    UB=9;
%mend; 

The problem is that the imputed value of this particular variable must be different from the imputed value of the primary_profession variable and I must specify this restriction within this macro. So far I managed to come up with a solution for extreme values:

 

 

%macro bound_secondary_profession;
    LB=1;
    UB=9;
    IF primary_profession=1 then LB=2;
    IF primary_profession=9 then UB=8;
%mend;

But what if primary_profession is equal, let's say 2? How can I impose that the number 2 cannot be chosen, using LB and UB? 

 

This is more of a logic challenge rather than a SAS programming challenge, but I've been struggling with this issue for quite some time and I still can't find a way out.

 

Thank you very much for your support.

 

Best regards

 


 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 563 views
  • 0 likes
  • 2 in conversation