BookmarkSubscribeRSS Feed
ZoeZoe
Calcite | Level 5

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?

3 REPLIES 3
Reeza
Super User

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?


 

ZoeZoe
Calcite | Level 5

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

 

ZoeZoe
Calcite | Level 5

Also, I want to use the Code/ Data steps to add the two other columns to my existing table

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1263 views
  • 0 likes
  • 2 in conversation