BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cruise
Ammonite | Level 13

I have a census population by counties and age categories in wide format as shown in the Image 2. Can you please help organize it to a narrow format in Image1?

 

I tried e.g.,: if agecat1 then agecat=1; else

                   if agecat2 then agecat=2; else ..

which creates only agecat=1.

 

Image 1: data I want:

wanted.png

Image 2: data I have

have.png

1 ACCEPTED SOLUTION

Accepted Solutions
Cruise
Ammonite | Level 13
Thanks a lot. Below just worked out.
proc transpose data=c.temp out=c.temp1;
by countycode;
run;

View solution in original post

6 REPLIES 6
novinosrin
Tourmaline | Level 20

Cruise, you should be on cruise control with proc transpose with tons of syntax on  a google search

Cruise
Ammonite | Level 13
Thanks a lot. Below just worked out.
proc transpose data=c.temp out=c.temp1;
by countycode;
run;
novinosrin
Tourmaline | Level 20

Well done! That's the spirit. Have a good evening. Mark your own answer as correct and please close the thread. Good job mate!

Cruise
Ammonite | Level 13
do you know how to close the thread?
novinosrin
Tourmaline | Level 20

Well, you have. Some original posters never mark an answer and the question stays open for ages. I would assume they want more responses, however if it's simple i seriously wonder why they lack the common sense to know that they are not gonna get any more. lol. Marking the answer is closing the thread.

 

I'm sure somebody may still come to this thread and offer like, "hey, here is an array solution. lol" that's like peanuts alongside my beer seeing such messages 🙂

Cruise
Ammonite | Level 13
Gotcha. Have a wonderful evening.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1575 views
  • 3 likes
  • 2 in conversation