BookmarkSubscribeRSS Feed
nana_confused
Calcite | Level 5

I'm having some problems with to categorize the characteristics of each variable using quartiles. Using the code below.

ods trace on;
/* Calculate Means and Standard Deviations */
PROC MEANS DATA=CoAnl.Combined_analysis MEAN STDDEV;
  CLASS Quartiles;
  VAR avg_Risk_Physical_Activity avg_dem_pctn4 Dem_Poverty_PC_Income avg_Out_Depres_Disor_CT;
  OUTPUT OUT=Means_StdDevs MEAN=Mean_ STDDEV=StdDev_;
RUN;
/* Perform ANOVA with LSMEANS for p-values */
PROC GLM DATA=CoAnl.Combined_analysis;
  CLASS Quartiles;
  MODEL avg_Risk_Physical_Activity avg_dem_pctn4 Dem_Poverty_PC_Income avg_Out_Depres_Disor_CT = Quartiles;
  LSMEANS Quartiles / adjust=tukey;
RUN;
ods trace off;
ods output  OverallANOVA=table22;
PROC GLM DATA=CoAnl.Combined_analysis;
  CLASS Quartiles;
  MODEL avg_Risk_Physical_Activity avg_dem_pctn4 Dem_Poverty_PC_Income avg_Out_Depres_Disor_CT = Quartiles;
  LSMEANS Quartiles / adjust=tukey;
RUN;
proc sql;
create table FINAL2 as
select a.Variable,a.MeanSD, 
b.Probf label='p-Value'
from table_Mean a left join table22(where =(source="Model"))b
on a.variable =b.dependent;
quit;
Proc print data=FINAL2;
run;
Result

 Obs Variable MeanSD ProbF12 4

 Income14.9(8.6)0.1919
 Depressive Disorder17.3(5.4)<.0001
physical activity 19.7(8.5)0.2182
 Bachelors Degree or Higher33.9(14.7)0.4753
I tried to put the quartiles level in the Final table above when I used the proc print to make it seem like the image below, butI didn't know the appropriate code for that.
Result
 Depression Quartiles N Obs Variable   Mean Std Dev0 21
avg_Risk_Physical_Activity
avg_dem_pctn4
Dem_Poverty_PC_Income
avg_Out_Depres_Disor_CT
 1 11
avg_Risk_Physical_Activity
avg_dem_pctn4
Dem_Poverty_PC_Income
avg_Out_Depres_Disor_CT

2 3
avg_Risk_Physical_Activity
avg_dem_pctn4
Dem_Poverty_PC_Income
avg_Out_Depres_Disor_CT

3 29
avg_Risk_Physical_Activity
avg_dem_pctn4
Dem_Poverty_PC_Income
avg_Out_Depres_Disor_CT
 
22.1945351
30.2583750
17.3667744
12.2072732
11.9459745
12.1870208
11.2971989
2.8700233
21.3504732
32.1421576
16.2652755
16.6428227
6.4469325
22.3623002
8.7059777
0.8111580
19.4700000
35.8216667
17.3083333
17.9250000
6.9890414
18.1325786
8.6883663
1.0158125
17.3202876
36.7880271
12.3661449
21.2076199
5.6867116
12.5118479
5.5296109
4.8850090
 
Your help is really appreciated.
1 REPLY 1
Reeza
Super User
Perhaps the format of your post is garbled but I'm not understanding the question unfortunately.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 424 views
  • 0 likes
  • 2 in conversation