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

I would like to know how I can convert this formula into SAS code? Thanks in advance

bio.cov <- bio.cov %>% mutate(female = ifelse(sex == 0, TRUE, FALSE),

                   kappa=ifelse(female, 61.9, 79.6),

                   alpha=ifelse(female,-0.329,-0.411),

                   srblack = ethnicity %in% c(4, 4001,4002,4003),

                   eGFR = 141 * pmin(creatinine/kappa, 1)^alpha *

                                pmax(creatinine/kappa, 1)^-1.209 *

                                0.993^age * ifelse(female, 1.018, 1) *

                                ifelse(srblack, 1.159, 1))
1 ACCEPTED SOLUTION

Accepted Solutions
japelin
Rhodochrosite | Level 12

how about this code?

But not tested because I don't know data structure and have no data.

 

 

data bio;
  set bio;
  female=ifn(sex=0, 1, 0);
  kappa =ifn(female, 61.9, 79.6);
  alpha =ifn(female,-0.329,-0.411);
  srblack=ifn(ethnicity in (4,4001,4002,4003),1,0);
  eGFR = 141 * min(creatinine/kappa, 1)**alpha *
               max(creatinine/kappa, 1)**-1.209 *
               0.993**age * ifn(female, 1.018, 1) *
               ifn(srblack, 1.159, 1);
run;

 

 

View solution in original post

4 REPLIES 4
japelin
Rhodochrosite | Level 12

how about this code?

But not tested because I don't know data structure and have no data.

 

 

data bio;
  set bio;
  female=ifn(sex=0, 1, 0);
  kappa =ifn(female, 61.9, 79.6);
  alpha =ifn(female,-0.329,-0.411);
  srblack=ifn(ethnicity in (4,4001,4002,4003),1,0);
  eGFR = 141 * min(creatinine/kappa, 1)**alpha *
               max(creatinine/kappa, 1)**-1.209 *
               0.993**age * ifn(female, 1.018, 1) *
               ifn(srblack, 1.159, 1);
run;

 

 

mantubiradar19
Quartz | Level 8

Hi Kawakami, 

 

Thanks for your help, suppose if my data doesn't have the information for ethnicity, can I write the formula like this?

data bio;
  set bio;
  female=ifn(sex=0, 1, 0);
  kappa =ifn(female, 61.9, 79.6);
  alpha =ifn(female,-0.329,-0.411);
  eGFR = 141 * min(creatinine/kappa, 1)**alpha *
               max(creatinine/kappa, 1)**-1.209 *
               0.993**age * ifn(female, 1.018, 1)
run;
japelin
Rhodochrosite | Level 12

I think it's fine.

You're just missing a semicolon at the end.

 

               0.993**age * ifn(female, 1.018, 1);
mantubiradar19
Quartz | Level 8
Thank you very much ~ let me try this code!

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1176 views
  • 1 like
  • 2 in conversation