BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
brianI1
Calcite | Level 5

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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. 

View solution in original post

6 REPLIES 6
novinosrin
Tourmaline | Level 20

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. 

brianI1
Calcite | Level 5

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!

Tom
Super User Tom
Super User

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.

 

 

brianI1
Calcite | Level 5

Exactly! Thank you for your response!

Kurt_Bremser
Super User

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.

brianI1
Calcite | Level 5

@Kurt_BremserThank you for your response. The mistake was the output statement.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
LIBNAME 101

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.

Discussion stats
  • 6 replies
  • 1081 views
  • 0 likes
  • 4 in conversation