DATA Step, Macro, Functions and more

Macro Question

Accepted Solution Solved
Reply
Contributor
Posts: 32
Accepted Solution

Macro Question

Can someone please help me to fix this macro issue? I cant find anything from the log file...

%LEt Retail_30_B = .165;
%Let Retail_30_G = .165;
%Let Retail_30_B_DF = 1;
%Let Retail_30_G_DF = 1;

%LEt Retail_90_B = .165;
%Let Retail_90_G = .165;
%Let Retail_90_B_DF = 1;
%Let Retail_90_G_DF = 1;

%Let Mail_B = .25;
%Let Mail_G = .73;
%Let MAil_B_DF = 0;
%Let Mail_G_DF = 0;

%Let Specialty_Disc = .17;
%Let Specialty_DF = 0;

data final;
set Claims_Join;

MAC =  macunitcost_num * qty_disp;
format Ingrediant_Cost 15.5 Final_ING_Cost 15.5;

if retail90_30 = 'Retail 30'and Type = 'Brand' then Ingrediant_Cost = Pre_AWP*(1-(&Retail_30_B.));
else if retail90_30 = 'Retail 30' and type = 'Generic' and MAC = . then Ingrediant_Cost = Pre_AWP*(1-(&Retail_30_G.));
else if type = 'Generic' and MAC <> . then Ingrediant_Cost = MAC;
else if retail90_30 = 'Retail 90'and Type = 'Brand' then Ingrediant_Cost = Pre_AWP*(1-(&Retail_90_B.));
else if retail90_30 = 'Retail 90' and type = 'Generic' and MAC = . then Ingrediant_Cost = Pre_AWP*(1-(&Retail_90_G.));
else specialty_ind = 'Y' then Ingrediant_Cost = Pre_AWP*(1-(&Specialty_Disc.));
Final_ING_Cost = min(U_and_C, Ingrediant_Costpe);
run;


Accepted Solutions
Solution
‎10-04-2011 05:52 PM
PROC Star
Posts: 7,474

Macro Question

It would really help if you provided sample data, in the form of a datastep, when posting your questions.

I would think that the following is closer to what you were trying to submit.  The problems I noticed were the use of <> which I presume meant NE, a statement where you indicated else specialty_ind=etc., etc, but looked like you meant else if, and you have a variable that may or may not be misspelled Ingrediant_Costpe (above and beyond the Ingrediant part), a the use of single quotes around variables that contain spaces:

data final;

  set Claims_Join;

  MAC =  macunitcost_num * qty_disp;

  format Ingrediant_Cost 15.5 Final_ING_Cost 15.5;

  if retail90_30 = "Retail 30" and Type = 'Brand' then Ingrediant_Cost = Pre_AWP*(1-(&Retail_30_B.));

  else if retail90_30 = "Retail 30" and type = 'Generic' and MAC = . then Ingrediant_Cost = Pre_AWP*(1-(&Retail_30_G.));

  else if type = 'Generic' and MAC NE . then Ingrediant_Cost = MAC;

  else if retail90_30 = "Retail 90" and Type = 'Brand' then Ingrediant_Cost = Pre_AWP*(1-(&Retail_90_B.));

  else if retail90_30 = "Retail 90" and type = 'Generic' and MAC = . then Ingrediant_Cost = Pre_AWP*(1-(&Retail_90_G.));

  else IF specialty_ind = 'Y' then Ingrediant_Cost = Pre_AWP*(1-(&Specialty_Disc.));

  Final_ING_Cost = min(U_and_C, Ingrediant_Cost);

run;

View solution in original post


All Replies
Frequent Contributor
Posts: 104

Macro Question

There's not enough information to help you yet.  Can you turn on macro diagnostics like:  options mprint macrogen;  ahead of your macro, submit, and post the log please.

Contributor
Posts: 32

Macro Question

ERROR 388-185: Expecting an arithmetic operator.

Is there any syntax error here?

data Claims_final;
set Claims_Join;

MAC =  macunitcost_num * qty_disp;
format Ingrediant_Cost 15.5 Final_ING_Cost 15.5;

if retail90_30 = 'Retail 30'and Type = 'Brand' then Ingrediant_Cost = Pre_AWP*(1-(&Retail_30_B.));
else if retail90_30 = 'Retail 30' and Type = 'Generic' and MAC = . then Ingrediant_Cost = Pre_AWP*(1-(&Retail_30_G.));
else if type = 'Generic' and MAC <> . then Ingrediant_Cost = MAC;
else if retail90_30 = 'Retail 90'and Type = 'Brand' then Ingrediant_Cost = Pre_AWP*(1-(&Retail_90_B.));
else if retail90_30 = 'Retail 90' and Type = 'Generic' and MAC = . then Ingrediant_Cost = Pre_AWP*(1-(&Retail_90_G.));
else specialty_ind = 'Y' then Ingrediant_Cost = Pre_AWP*(1-(&Specialty_Disc.));
Final_ING_Cost = min(U_and_C, Ingrediant_Costpe);
run;

Solution
‎10-04-2011 05:52 PM
PROC Star
Posts: 7,474

Macro Question

It would really help if you provided sample data, in the form of a datastep, when posting your questions.

I would think that the following is closer to what you were trying to submit.  The problems I noticed were the use of <> which I presume meant NE, a statement where you indicated else specialty_ind=etc., etc, but looked like you meant else if, and you have a variable that may or may not be misspelled Ingrediant_Costpe (above and beyond the Ingrediant part), a the use of single quotes around variables that contain spaces:

data final;

  set Claims_Join;

  MAC =  macunitcost_num * qty_disp;

  format Ingrediant_Cost 15.5 Final_ING_Cost 15.5;

  if retail90_30 = "Retail 30" and Type = 'Brand' then Ingrediant_Cost = Pre_AWP*(1-(&Retail_30_B.));

  else if retail90_30 = "Retail 30" and type = 'Generic' and MAC = . then Ingrediant_Cost = Pre_AWP*(1-(&Retail_30_G.));

  else if type = 'Generic' and MAC NE . then Ingrediant_Cost = MAC;

  else if retail90_30 = "Retail 90" and Type = 'Brand' then Ingrediant_Cost = Pre_AWP*(1-(&Retail_90_B.));

  else if retail90_30 = "Retail 90" and type = 'Generic' and MAC = . then Ingrediant_Cost = Pre_AWP*(1-(&Retail_90_G.));

  else IF specialty_ind = 'Y' then Ingrediant_Cost = Pre_AWP*(1-(&Specialty_Disc.));

  Final_ING_Cost = min(U_and_C, Ingrediant_Cost);

run;

Contributor
Posts: 32

Macro Question

Thanks a lot Art297.

Super User
Posts: 10,028

Macro Question

It would be helpful if you can post all the content of log.

options mprint mlogic symbolgen;

Ksharp

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 173 views
  • 0 likes
  • 4 in conversation