BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Catherine18
Fluorite | Level 6
Open p104p04.sas from the practices folder.

  • Create a new column named SqMiles by multiplying Acres by .0015625.
  • Create a new column named Camping as the sum of OtherCamping, TentCampers, RVCampers, and BackcountryCampers.
  • Format SqMiles and Camping to include commas and zero decimal places.
  • Modify the KEEP statement to include the new columns.
  • Submit the program.
I tried the following codes but I am getting different answers.

data np_summary_update; set pg1.np_summary; keep Reg ParkName DayVisits OtherLodging Acres SqMiles Camping; SqMiles=Acres*.0015625; Camping=sum(OtherCamping,TentCampers, RVCampers,BackcountryCampers); format SqMiles comma6. Camping comma10.; run;

So, the question is and the answers in the answerkey are: SqMiles  1,014 and Camping 6,375.
and my answers are: SqMile 77 and Camping 201,741
I copied and pasted the codes from the answer key and still geting the same results (77, 201741). I did not sort the data in anyway nor the question asked to sort the data.
Did anyone else had the same issue?
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  My guess is that somehow the original dataset, pg1.np_summary got corrupted or lost rows. When you run a PROC CONTENTS on pg1.np_summary, you should see 135 observations or rows and 10 columns or variables, as shown in the PROC CONTENTS output below:

Cynthia_sas_0-1632416717019.png

 

Another way to check is to look in your log. You should see something like this:

Cynthia_sas_1-1632416766884.png

  If you have anything OTHER than 135 as the number of observations for pg1.np_summary, then it is a good idea to re-run the data creation program again to refresh the data.

 

  When I run the program against the data with 135 observations, the first observation is for the ParkName value of Cape Krusenstern National Monument the SqMiles value is 1,014 and the Camping value is 6,375 . Please go back to the Course Overview instructions and re-run the program to re-create the data for the class. The answer key is correct and it seems like something happened to your data, perhaps accidentally that changed pg1.np_summary.

 

Cynthia

 

 

 

View solution in original post

7 REPLIES 7
Kurt_Bremser
Super User

You can check the validity of your code quite easily, by doing the calculation yourself with the values found in the dataset. After all, it's just one multiplication and adding of 4 values.

 

If the dataset is the result of an earlier task of yours, go back there to see if you calculate the correct values there.

Catherine18
Fluorite | Level 6
The calculations are correct but it has multiple rows and the question is about the first row. I am getting the exact set of results somewhere at the bottom but not in the first row. So I think it is some sorting issue. But, I did not sort the data neither the question asked to sort it.
Reeza
Super User
Is Acres 648,960 or 4928 in the original data set?
Are you sure you're using the correct input data set?
Catherine18
Fluorite | Level 6
I am positive that I am using the correct data (unless it got corrupted somehow) because I copied and pasted the codes from the answer key and I am getting the same results as my code's output. This is my first row:
Reg ParkName DayVisits Other Acres SqMiles Camping
1 NE Acadia National Park 3,303,393 0 49,057.36 77 201,741
Cynthia_sas
SAS Super FREQ

Hi:

  My guess is that somehow the original dataset, pg1.np_summary got corrupted or lost rows. When you run a PROC CONTENTS on pg1.np_summary, you should see 135 observations or rows and 10 columns or variables, as shown in the PROC CONTENTS output below:

Cynthia_sas_0-1632416717019.png

 

Another way to check is to look in your log. You should see something like this:

Cynthia_sas_1-1632416766884.png

  If you have anything OTHER than 135 as the number of observations for pg1.np_summary, then it is a good idea to re-run the data creation program again to refresh the data.

 

  When I run the program against the data with 135 observations, the first observation is for the ParkName value of Cape Krusenstern National Monument the SqMiles value is 1,014 and the Camping value is 6,375 . Please go back to the Course Overview instructions and re-run the program to re-create the data for the class. The answer key is correct and it seems like something happened to your data, perhaps accidentally that changed pg1.np_summary.

 

Cynthia

 

 

 

Catherine18
Fluorite | Level 6
I am getting a total of 135 observations and it's unsorted. I have 7 variables since I dropped a couple of them. I am not sure what went wrong but I will try re-creating the data. Thanks!
Catherine18
Fluorite | Level 6

I tried re-uploading the data and now I am getting correct results. Thanks, @Cynthia_sas and everyone! 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 7 replies
  • 1684 views
  • 7 likes
  • 4 in conversation