BookmarkSubscribeRSS Feed
Ishor
Calcite | Level 5

 I have following data.

 

Age   Zone

20    FN

21    CN

22    FN

20     CN

20   CN

and so on

 

 

I need following.

                 Age

Zone   20   21   22   23

FN      1      0    1      0 

CN      2      1    0      0

 

Thanks in Advance

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Normally, turning a long data set into a wide data set is not a good practice. I would recommend you leave your data set in the long format for most purposes, as almost all SAS PROCs are designed to work on the long data set.

 

So, why do you want a wide data set? Please explain clearly 


If you want an output report in the wide format, then please state that clearly; again a long data set can be used to create a wide report.

--
Paige Miller
Reeza
Super User
proc tabulate data=have;
class age zone;
table zone, age*N;
run;

@Ishor wrote:

 I have following data.

 

Age   Zone

20    FN

21    CN

22    FN

20     CN

20   CN

and so on

 

 

I need following.

                 Age

Zone   20   21   22   23

FN      1      0    1      0 

CN      2      1    0      0

 

Thanks in Advance




ballardw
Super User

You should state whether your "need" is for a data set for further manipulation or a report that people will read. The "need" that you show is generally a poor form for most forms of manipulation further.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 555 views
  • 0 likes
  • 4 in conversation