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

For the life of me, I can't figure this out!

Using PROC TRANSPOSE, I'm trying to get from this (hopefully these tables show up correctly):

MAIN_CITY_NMGEO_OPEN_TO_RO_OPEN_HRS_MedianRO_OPEN_TO_RO_START_HRS_MedianRO_START_TO_RO_FINISH_H_MedianRO_FINISH_TO_GEO_END_HR_MedianGEO_OPEN_DAYS_Median
CONSHOHOCKEN1.32.350.830.55.5
PENNSAUKEN1.86.327.32.51.3
VINELAND1.70.1128.41.53.1
TRENTON2.50.347.314.73.1
NEW CASTLE25.529.435
SOUDERTON-22.92.80.30.2

 

 

to this:

MAIN_CITY_NMAnalysis_VariableValue
CONSHOHOCKENGEO_OPEN_TO_RO_OPEN_HRS_Median1.3
CONSHOHOCKENRO_OPEN_TO_RO_START_HRS_Median2.3
CONSHOHOCKENRO_START_TO_RO_FINISH_H_Median50.8
CONSHOHOCKENRO_FINISH_TO_GEO_END_HR_Median30.5
CONSHOHOCKENGEO_OPEN_DAYS_Median5.5
PENNSAUKENGEO_OPEN_TO_RO_OPEN_HRS_Median1.8
PENNSAUKENRO_OPEN_TO_RO_START_HRS_Median6.3
PENNSAUKENRO_START_TO_RO_FINISH_H_Median27.3
PENNSAUKENRO_FINISH_TO_GEO_END_HR_Median2.5
PENNSAUKENGEO_OPEN_DAYS_Median1.3
VINELANDGEO_OPEN_TO_RO_OPEN_HRS_Median1.7
VINELANDRO_OPEN_TO_RO_START_HRS_Median0.1
VINELANDRO_START_TO_RO_FINISH_H_Median128.4
VINELANDRO_FINISH_TO_GEO_END_HR_Median1.5
VINELANDGEO_OPEN_DAYS_Median3.1
TRENTONGEO_OPEN_TO_RO_OPEN_HRS_Median2.5
TRENTONRO_OPEN_TO_RO_START_HRS_Median0.3
TRENTONRO_START_TO_RO_FINISH_H_Median47.3
TRENTONRO_FINISH_TO_GEO_END_HR_Median14.7
TRENTONGEO_OPEN_DAYS_Median3.1
NEW CASTLEGEO_OPEN_TO_RO_OPEN_HRS_Median2
NEW CASTLERO_OPEN_TO_RO_START_HRS_Median5.5
NEW CASTLERO_START_TO_RO_FINISH_H_Median29.4
NEW CASTLERO_FINISH_TO_GEO_END_HR_Median3
NEW CASTLEGEO_OPEN_DAYS_Median5
SOUDERTONGEO_OPEN_TO_RO_OPEN_HRS_Median-2
SOUDERTONRO_OPEN_TO_RO_START_HRS_Median2.9
SOUDERTONRO_START_TO_RO_FINISH_H_Median2.8
SOUDERTONRO_FINISH_TO_GEO_END_HR_Median0.3
SOUDERTONGEO_OPEN_DAYS_Median0.2

 

For some reason, I just can't figure it out.  Is there anyone out there who's REALLY GOOD with PROC TRANSPOSE who could have a stab at this?

THANKS!!!

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Basically the same answer as @Puwang, but you don't need to sort your data and the following accomplishes the renaming of variables according to your example:

proc transpose data = have out=want (rename=(col1=value)) name=analysis_variable;
	by MAIN_CITY_NM notsorted;
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

4 REPLIES 4
Puwang
Obsidian | Level 7

The following code works (a is the name of your original table):

proc sort data = work.a;
	by MAIN_CITY_NM;
run;
proc transpose data = work.a out=work.a_trans;
	by MAIN_CITY_NM;
run;
art297
Opal | Level 21

Basically the same answer as @Puwang, but you don't need to sort your data and the following accomplishes the renaming of variables according to your example:

proc transpose data = have out=want (rename=(col1=value)) name=analysis_variable;
	by MAIN_CITY_NM notsorted;
run;

Art, CEO, AnalystFinder.com

 

bendsteel6
Obsidian | Level 7

even simpler!  Thank you!!!

bendsteel6
Obsidian | Level 7

WOW!!! So simple and works great!  Thank you!!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 916 views
  • 0 likes
  • 3 in conversation