Is it possible to aggregate a column and put the aggregated numbers into an existing table in SAS Prepare Data? What codes should I look at?
Yes it's possible. Please show an example of what you're trying to do and more details so we can help provide an appropriate solution.
For example, are you adding a new column? New rows? Does it need to have specific names?
Also, are you using SAS Studio with the Tasks or coding with data steps?
@ZoeZoe wrote:
Is it possible to aggregate a column and put the aggregated numbers into an existing table in SAS Prepare Data? What codes should I look at?
Hi,
Thanks for your reply. I have a table named “Test” in Prepare Data in SAS data studio. My Table looks like this:
Test
Sequence | Province | ER_Code | NOC_Code | Number of jobs |
2019m1 | QC | Capitale-Nationale | 0011 | 1 |
2019m1 | QC | Chaudi�re-Appalaches | 0011 | 1 |
2019m1 | QC | Montr�al | 0011 | 1 |
2019m1 | NL | Avalon Peninsula | 0012 | 3 |
2019m1 | NL | West Coast--Northern Peninsula--Labrador | 0012 | 3 |
2019m1 | PE | Prince Edward Island | 0012 | 2 |
2019m1 | NS | Halifax | 0012 | 9 |
2019m2 | QC | Capitale-Nationale | 0011 | 2 |
2019m2 | QC | Chaudi�re-Appalaches | 0011 | 3 |
2019m2 | QC | Montr�al | 0011 | 4 |
2019m2 | NL | Avalon Peninsula | 0012 | 3 |
2019m2 | NL | West Coast--Northern Peninsula--Labrador | 0012 | 3 |
2019m2 | PE | Prince Edward Island | 0012 | 2 |
2019m2 | NS | Halifax | 0012 | 9 |
I want the number of jobs aggregated by sequence & NOC-Code; and sequence & NOC-Code & province and add two new columns to my existing table “Test” as this:
Test
Sequence | Province | ER_Code | NOC_Code | Number of jobs | Aggregated by sequence & NOC-Code | Aggregated by sequence & NOC-Code & province |
2019m1 | QC | Capitale-Nationale | 0011 | 1 | 3 | 3 |
2019m1 | QC | Chaudi�re-Appalaches | 0011 | 1 | 3 | 3 |
2019m1 | QC | Montr�al | 0011 | 1 | 3 | 3 |
2019m1 | NL | Avalon Peninsula | 0012 | 3 | 17 | 6 |
2019m1 | NL | West Coast--Northern Peninsula--Labrador | 0012 | 3 | 17 | 6 |
2019m1 | PE | Prince Edward Island | 0012 | 2 | 17 | 2 |
2019m1 | NS | Halifax | 0012 | 9 | 17 | 9 |
2019m2 | QC | Capitale-Nationale | 0011 | 1 | 9 | 9 |
2019m2 | QC | Chaudi�re-Appalaches | 0011 | 1 | 9 | 9 |
2019m2 | QC | Montr�al | 0011 | 1 | 9 | 9 |
2019m2 | NL | Avalon Peninsula | 0012 | 3 | 17 | 6 |
2019m2 | NL | West Coast--Northern Peninsula--Labrador | 0012 | 3 | 17 | 6 |
2019m2 | PE | Prince Edward Island | 0012 | 2 | 17 | 2 |
2019m2 | NS | Halifax | 0012 | 9 | 17 | 9 |
Also, I want to use the Code/ Data steps to add the two other columns to my existing table
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!What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: