Desktop productivity for business analysts and programmers

Using IF statement to substitute column values

Reply
Occasional Contributor
Posts: 11

Using IF statement to substitute column values

Hi

I need to substitute blank values in column "January Estimate" with the value from "6m Avg" every time On Promotion is "N" and January estimate is "." But for On Promotion "Y" it should retain the same value in the estimate column

ProdCodeLongDescriptionQtyOnHandOn PromotionJanuary Estimate6m Avg
1111XXX54Y7218
222YYY33N.16
354656ZZZ52Y6116

How do I do it?

Thanks

Esteemed Advisor
Posts: 7,301

Re: Using IF statement to substitute column values

You need to show example data that captures both conditions and, for clarity, what you want the resulting file to look like. I, personally, would also like to see you propose code to solve the problem.

Super User
Posts: 1,117

Re: Using IF statement to substitute column values

Hi, please try the below code , However i agree with Art , if you provide more details then you will get the more appropriate response.

i just tried with a simple if then statement. Hope this helps.

data want;

set have;

if OnPromotion='N' and JanuaryEstimate eq . then JanuaryEstimate=_6mAvg;

run;

Thanks,

Jag

Thanks,
Jag
Ask a Question
Discussion stats
  • 2 replies
  • 302 views
  • 0 likes
  • 3 in conversation