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

Sorry about the complicated title. For my data (previewed below), I am looking to find the adult_pop number for each county. For example, for Rio Blanco county, I am looking for a way to ask SAS to add 4381 + 1190 + (any other adult_pop numbers for the county) and tell me the total adult_pop for the county. There are over 1,000 lines of code in the data set. What is a simple way to code this? Thanks

 

Screenshot 2023-11-05 at 3.26.08 PM.png

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

Thiis is exactly what PROC SUMMARY (alias PROC MEANS) was designed to do:

 

proc summary data=have nway;
  vars adult_pop;
  class count;
  output out=want (drop=_type_) sum=total_adult_pop;
run;

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

1 REPLY 1
mkeintz
PROC Star

Thiis is exactly what PROC SUMMARY (alias PROC MEANS) was designed to do:

 

proc summary data=have nway;
  vars adult_pop;
  class count;
  output out=want (drop=_type_) sum=total_adult_pop;
run;

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 500 views
  • 0 likes
  • 2 in conversation