Okay that makes sense. So I am assuming the following statement causes Start_Date to change to 01JUL2017:
if Start_Date = '01DEC2016'd then do;
Start_Date = '01JUL2017'd;
End_Date = '31JUL2017'd;
output;
end;
What method can be used so that 01DEC2016 is recognized as Winter and 01JUL2017 as summer without compromising the above statement? Thank you for all your help by the way.
The smallest changes to the program would involve consolidating the calculations.
I'm making some assumptions on where I think you are headed. For example, I think you want all the observations, not just those that satisfy the WHERE statement. And I think you want 01DEC2016 output only once. My best guess:
data work.extended;
set prg.discount2016;
if Start_Date = '01DEC2016'd then do;
Promotion = 'Holiday Bonus';
Season = 'Winter';
output;
Promotion = ' ';
Season = ' ';
Start_Date = '01JUL2017'd;
End_Date = '31JUL2017'd;
output;
end;
else if start_date = '01DEC2016'd then do;
season = 'Summer';
output;
end;
else output;
drop Unit_Sales_Price;
run;
Thanks. I included the where statement because I am only wanting to output the 01DEC2016 and 01JUL2017 observations. When I use the method described above only winter is shown not summer.
OK, I know I was guessing a little at the desired results. It's clear now (I think). Here's a rewrite:
data work.extended;
set prg.discount2016;
where Start_Date = '01DEC2016'd;
Promotion = 'Holiday Bonus';
Season = 'Winter';
output;
Promotion = ' ';
Start_Date = '01JUL2017'd;
End_Date = '31JUL2017'd;
season = 'Summer';
output;
drop Unit_Sales_Price;
run;
Thank you soooo much for your help. I have learnt a lot!!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: