I am a beginner user in SAS. I have a table Dose_turn with columns Month for month and Doses for dose of different products. I want to set value of doses of specific months to 0 using a loop wherever its the specific product P13.
If I want to change the value of just one month, the code is simple and is as follows:
Data Dose_Trn_2;
Set Dose_Trn;
if Prd_Name = 'P13' and Month= 'Mnth_1' then Doses=0;
run;
Now if i want to change for example for 4 months, can I achieve the same using a loop where month automatically takes in the values ‘Mnth_1’, ‘Mnth_2’, ‘Mnth_3’, ‘Mnth_4’ based on some condition/increment in the loops like do while or do until loops.
Data Dose_Trn_2;
Set Dose_Trn;
if Prd_Name = 'P13' and Month= 'Mnth_1' then Doses=0;
if Prd_Name = 'P13' and Month= 'Mnth_2' then Doses=0;
if Prd_Name = 'P13' and Month= 'Mnth_3' then Doses=0;
if Prd_Name = 'P13' and Month= 'Mnth_4' then Doses=0;
run;
Is there any way to use loops to change the value of Month variable than writing separate statements everytime?