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

 

Screen Shot 2022-01-17 at 8.01.01 PM.pngScreen Shot 2022-01-17 at 8.00.24 PM.png

okay the first image with the writing is the original from the survey. There were 4 possible answers, the right answer being:1 small apple.

I did what you recommended, and recoded it to what the second image is and if somebody answered wrong it would be 0 and if it was right, they got a 1. 

In sas i imported the data. and then put the code listed above. 

PROC TTEST DATA=work.import ALPHA=.05;
    PAIRED pre*post;
RUN;

 

 

Tom
Super User Tom
Super User

If that second photograph is how EXCEL shows your spreadsheet then the reason the variable is CHARACTER in SAS is because you made it character in EXCEL.  That is what the little green triangles mean.

Reeza
Super User

Typically what would happen is you import the raw data, you do not recode it manually. This is actually important as it allows for full scientific reproducibility and is an important part of the scientific process. Papers these days have been retracted because someone coded things as 1 or 0 and then someone else flipped that coding. Doing things manually is not the correct approach.

I would expect to see code that looks like the following:

*import raw data;
proc import datafile='myExcel.xlsx' out=rawData dbms=XLSX replace;run;

*clean up data;
data cleanData;
set rawData;
if Q3 in ('1 small apple') then Q3_Code = 1;
else Q3_Code=0;
/*rest of data cleaning required*/

run;

*Wrangle into format for pre-post, not sure because you have shown only the pre file;
data clean_long_data;
set cleanData;
/*merge cleanDatapre cleandatapost;*/
run;

*T-Test;
proc ttest data=clean_long_data;
....
run;



So far all you've shown is the first step. Which is the last step in what you need. Somewhere in that code above is where you would apply your fix for the data types.

tom_grant
SAS Super FREQ

Can you state your null hypothesis & alternative hypothesis precisely?  Do you really want to have a test for each question or do you want to examine whether the % of correct answers across all respondents & all questions increased in the post survey?

 

Even though you can code responses as numeric (0 = incorrect, 1 = correct) for pre & post survey, you are really working with a categorical variable at the individual & question level.

 

You may find that a chi-sq test is more appropriate if examining each question with the cohorts being correct responders & incorrect responders on pre-test.

 

If you are evaluating the effectiveness of the intervention across all questions, you could measure the difference in pre & post test scores.

 

Example:

ID     Pre-score  Post-score   Diff

1         75%           85%          +10%

2         50%           65%          +15%

...

 

Again, clearly stating your hypothesis would be very helpful

 

PaigeMiller
Diamond | Level 26

Most of us will not download XLSX (or other Microsoft Office) attachments, as they can be a security threat. The proper format to provide data is via SAS data step code (instructions).

--
Paige Miller
ecampos2
Calcite | Level 5

My hypothesis is: based on the intervention, did the participants increase in knowledge in diabetic related information?

we are testing each question individually to see if it was significant... I was also told to change each question into a ditcotimous numerical format, but i'm not sure if i'm supposed too because the answers are categorical. 

The first question in the survey was which food raises blood sugar levels the most? and examples of the answers is listed below.... 

Screen Shot 2022-01-24 at 4.05.48 PM.png

i changed it to dichotomous format (1,0). There were 4 possible answers (1/3 cheddar cheese, 1 0z pork, 3oz hamburger, and the right one which is 1 small apple). 0 for wrong answers and 1 for correct answer. 

Screen Shot 2022-01-24 at 4.00.53 PM.png 

but does that leave out important information?... can i still do the test test with it categorical answers? 

--> for question 2  i find it a bit more confusing.. the question is; according to the Plate method , non starchy vegetables are how much of your plate? 

Screen Shot 2022-01-24 at 4.02.36 PM.png

 i changed it to dichotomous format (1,0). There were 4 possible answers (the wrong ones are 1/4, 1/3 and 3/4. 1/2 is the correct answer). 0 for wrong answers and 1 for correct answer. 

Screen Shot 2022-01-24 at 4.02.53 PM.png

I also changed it to a ditcotimous format, but was told to change the answers to (.25,.33,.50,.75) instead and find the difference and then run the t test... but am not sure 

tom_grant
SAS Super FREQ
This link may help:
https://www.researchgate.net/post/How_can_I_perform_a_paired_sample_t-test_with_binary_data


Since you are looking at the respondent & Question level, you are really comparing the difference between pre & post correct answers, so the only possible values are:
0 (either got it incorrect on both pre & post or got it correct pre & post)
1 (got it incorrect on pre & correct on post)
-1 (got it correct on pre & incorrect on post) <- hopefully did not happen.
ecampos2
Calcite | Level 5

why do I keep getting this error : 

ERROR 22-322: Syntax error, expecting one of the following: *, :.
ERROR 76-322: Syntax error, statement will be ignored.
when my formula is :
PROC IMPORT DATAFILE=REFFILE
DBMS=XLS
OUT=WORK.IMPORT;
GETNAMES=YES;
RUN;
 
PROC CONTENTS DATA=WORK.IMPORT; RUN;
%web_open_table(WORK.IMPORT);
proc ttest data=work.import;
Paired Q_3 pre * Q_3 post;
run;
tom_grant
SAS Super FREQ
Your code has spaces in variable names - probably Q_3pre or Q_3_pre
ecampos2
Calcite | Level 5

okay I changed the format fro just pre and post, and no I'm getting 2 errors:

 

ERROR:Variable Pre in list does not match type prescribed for this list.

ERROR:Variable Post in list does not match type prescribed for this list.

Reeza
Super User
Your variables are character when they should be numeric, Excel doesn't allow you to specify the data type while importing it, so you need to convert it after the import but before the proc ttest or anova.
tom_grant
SAS Super FREQ

Here is a quick way to make sure your variable names conform to SAS naming conventions when importing data:

1.  Go to preference in SAS Studio

tom_grant_0-1646759927177.png

2.  On the Tables Tab, update the Polices: SAS variable name policy = V7 & SAS member name policy = COMPATIBLE

tom_grant_1-1646760099037.png

3. Click Save

This will force variables to be compatible with SAS naming convention (example:. replace spaces with underscores)

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!

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
  • 26 replies
  • 2409 views
  • 4 likes
  • 5 in conversation