Help using Base SAS procedures

Trouble with PROC TRANSPOSE

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

Trouble with PROC TRANSPOSE

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!!!


Accepted Solutions
Solution
‎09-01-2017 10:30 AM
PROC Star
Posts: 8,167

Re: Trouble with PROC TRANSPOSE

Posted in reply to bendsteel6

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


All Replies
SAS Employee
Posts: 31

Re: Trouble with PROC TRANSPOSE

Posted in reply to bendsteel6

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;
Solution
‎09-01-2017 10:30 AM
PROC Star
Posts: 8,167

Re: Trouble with PROC TRANSPOSE

Posted in reply to bendsteel6

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

 

Contributor
Posts: 30

Re: Trouble with PROC TRANSPOSE

even simpler!  Thank you!!!

Contributor
Posts: 30

Re: Trouble with PROC TRANSPOSE

Posted in reply to bendsteel6

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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