Hi SAS instructors!
Now I am in lesson 7, practice, level 2
In this practice, there is one thing I think redundant or maybe I fall into a fallacy.
This is the requirement and the answer
The dataset is as below:
ParkName CampType CampCount
Acadia NP Tent 152,811
Acadia NP RV 46,629
Acadia NP Backcountry 1,324
Amistad NRA Tent 38
Amistad NRA RV 8,265
I am wondering why you retain the ParkName here, because the table has been in narrow version so the ParkName will not be set as missing after each iteration.
data camping_wide (keep= parkname tent rv backcountry);
set pg2.np_2016camping;
by ParkName;
retain Tent RV Backcountry;
if camptype='Tent' then
Tent=campcount;
else if camptype='RV' then
RV=campcount;
else BACKCOUNTRY=campcount;
format tent rv backcountry comma15.;
if last.ParkName then
output;
run;
I generate my code without retaining the ParkName and my result is similar to the one when applying your code
I also present the debugger here for iteration 4 for clarifying purpose.
If you retain the ParkName with any purpose that I did not notice, please let me know.
Warm regards,
Phil.
Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.