BookmarkSubscribeRSS Feed
EddieJackson
Calcite | Level 5

Hi all, thanks in advance.

 

I've been searching for a while and haven't been able to be successful to find a solution.

 

I'm looking at a bunch of survey data, and running the chi-square tests for categorical variables have been straightfoward with the following code that I'm using:

 

PROC SURVEYFREQ DATA=xxx;

cluster yyy;

strata zzz;

weight aaa;

VAR Kidney*Gender/row chisq;

RUN;

 

I have been trouble coming up with the code to run the t-tests similarly for continuous variables however. Could someone give me an example? The proc t-test doesn't seem appropriate for the large weighted survey data - is there a similar way to do this with surveymeans?

 

Thanks.

3 REPLIES 3
Reeza
Super User
Have you checked out the examples in the documentation? Does this seem relevant:
https://documentation.sas.com/?docsetId=statug&docsetVersion=15.1&docsetTarget=statug_surveymeans_ex...

In addition, you can likely use PROC SURVEYREG to get the test statistics and it will be the same results.
EddieJackson
Calcite | Level 5

I looked at he documentation provided, and came up with the following code which spit out a t value.

 

PROC SURVEYMEANS DATA= Analysis.Analysis;
cluster HOSP_NRD;
strata NRD_STRATUM;
weight DISCWT;
VAR Age;
DOMAIN CKD/diffmeans;
RUN;

 

Do you think this code is correct? Why is it that the output N's are still the unweighted N's rather than weighted N's (my weighted N's should be much higher)

 

If I do a simple proc t-test the results are similar but again, the N's are unweighted.

 

proc ttest data=Analysis.Analysis;
weight DISCWT;
class CKD;
var Age;
run;

Reeza
Super User
Are you sure? You have weight statements in both. So I assume when you run without a weight statement you get the same results, which is why you think it's unweighted?

I don't know your data so cannot know if your code is correct, I don't know the topics, variables or what you're trying to test. I would recommend making sure that the example code works on your computer then change your code to align with the example in a manner that makes sense.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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