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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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