BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sathish_jammy
Lapis Lazuli | Level 10

Dear Experts,

 

I want to visualize my data as a horizontal format with summing the year value.

 For example : 

data lkj;
input ID yearof;
cards;
132 2004
132 2004
132 2005
321 2010
321 2010
321 2015
run;

Required OP

 

ID2004200520102015
13221..
321..21

 

Kindly help me to transform in the given format.

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc report data=lkj;
    columns id yearof;
	define id/group;
	define yearof/across;
run;

By the way, this is counting, not summing.

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26
proc report data=lkj;
    columns id yearof;
	define id/group;
	define yearof/across;
run;

By the way, this is counting, not summing.

--
Paige Miller
Sathish_jammy
Lapis Lazuli | Level 10

Thank you for your support! @PaigeMiller @Ksharp @PeterClemmensen 

All your suggestion works well.

 

 

PeterClemmensen
Tourmaline | Level 20
proc sql;
    create table temp as
    select *,
           count(*) as count
    from lkj
    group by ID, yearof;
quit;

proc transpose data=temp out=want(drop=_NAME_) prefix=_;
    by ID;
    id yearof;
    var count;
run;
Ksharp
Super User

It is best tool for PROC TABULATE.

 

data lkj;
input ID yearof;
cards;
132 2004
132 2004
132 2005
321 2010
321 2010
321 2015
;
proc tabulate data=lkj;
class id yearof;
table id,yearof*n=' '*f=best.;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1764 views
  • 6 likes
  • 4 in conversation