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

Dears:

I have data in the following format:

Year    Code    Population 

2000   1001     10

2000   1001     15

2001   1001     4

2002   1001     3

2002   1001     5

2000   1002     5

2000   1002     8

2001   1002     10

2002   1002     25

2002  1002      30

 

I want to have a total population per year and code it as

Year  Code Population

2000   1001   25

2001   1001    4

2002   1001    8

2000   1002    13

2001   1002    10

2002   1002    55

 

And finally, I want to transpose the total population per year as

Code  Population_2000  Population_2001  Population_2002

1001           25                        4                             8

1002           13                       10                           55

Thank you very much for your help.

Lijalem

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

PROC REPORT does this in a single step:

proc report data=have;
column code population,year;
define code / group;
define population / analysis sum;
define year / "" across;
run;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

PROC REPORT does this in a single step:

proc report data=have;
column code population,year;
define code / group;
define population / analysis sum;
define year / "" across;
run;
Lijuu
Obsidian | Level 7
Thank you very much. Really Apreciated, it is working well.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 229 views
  • 0 likes
  • 2 in conversation