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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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