My syntax is word for word what is used for the solution however my output data doesn't separate the "Park" and Monument" rows. Both tables have Park and Monument. Please help.
data parks monuments;
set"&path/np_summary";
where type in ('NM', 'NP');
Campers=sum (OtherCamping, TentCampers, RVCampers, BackcountryCampers);
format Campers comma17.;
length ParkType $ 8;
if type='NP' then do;
ParkType='Park';
output=parks;
end;
else do;
Parktype='Monument';
output=monuments;
end;
keep Reg ParkName DayVisits OtherLodging Campers ParkType;
run;
hi @brianI1 I think your problem is the incorrect syntax
Correct one is output parks;
See if the below works
data parks monuments;
set "&path/np_summary";
where type in ('NM', 'NP');
Campers=sum (OtherCamping, TentCampers, RVCampers, BackcountryCampers);
format Campers comma17.;
length ParkType $ 8;
if type='NP' then do;
ParkType='Park';
output parks;
end;
else do;
Parktype='Monument';
output monuments;
end;
keep Reg ParkName DayVisits OtherLodging Campers ParkType;
run;
And here,set "&path/np_summary";
are you trying to resolve to a physical name rather than a logical name? This seemingly complicates reading ease.
hi @brianI1 I think your problem is the incorrect syntax
Correct one is output parks;
See if the below works
data parks monuments;
set "&path/np_summary";
where type in ('NM', 'NP');
Campers=sum (OtherCamping, TentCampers, RVCampers, BackcountryCampers);
format Campers comma17.;
length ParkType $ 8;
if type='NP' then do;
ParkType='Park';
output parks;
end;
else do;
Parktype='Monument';
output monuments;
end;
keep Reg ParkName DayVisits OtherLodging Campers ParkType;
run;
And here,set "&path/np_summary";
are you trying to resolve to a physical name rather than a logical name? This seemingly complicates reading ease.
Hello @novinosrin, That was exactly my mistake. Just little things like that can make a world of difference. The pathfile for "set" is just for training.
Thank you so much for your help!
You probably wanted OUTPUT statements instead of assignment statements. Didn't you see the note in the log about the uninitialized variables PARKS and MONUMENTS that these two assignment statements are reading from.
output=parks;
output=monuments;
If you didn't have the KEEP statement you would have both of those and the variable OUTPUT also in your dataset.
Exactly! Thank you for your response!
Show the solution you are referring to (preferably with a link to it), and we can show you what went wrong.
The log will alert you to possible problem locations, and you may have misunderstood the syntax of the output statement.
@Kurt_BremserThank you for your response. The mistake was the output statement.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.
Find more tutorials on the SAS Users YouTube channel.