/**** SAS Analysis syntax for data created from sample JBT Inquisit program *** This syntax will read in and clean the JBT data but will not run actual analyses such as T-tests or ANOVAs *** To adopt for your own use, you will need to change file paths *** Also, be sure to remember what is Category A and what is Category B in terms of your own uses (e.g., Cats vs. Dogs, Old vs. Young, etc.)*/ /*Reading in the raw data*/ DATA JBTData; INFILE "Q:\KLIFF Personnel\Joey\SampleStudyData.dat" DELIMITER='09'x firstobs=2; INPUT date time :$30. subject blockcode :$30. blocknum trialcode :$30. trialnum response :$30. correct latency stimulusnumber1 stimulusitem1 :$30. stimulusitem2 :$30. stimulusitem3 :$30. stimulusitem4 :$30.; RUN; /*** Creating a new variable that tells us whether a participant made a Level A or Level B response on each trial. *** Will need this information to exclude participants based on whether they made one response too much*/ data Work.JBTData; set Work.JBTData; If response='levelabutton' THEN levelaresponse=1; If response='levelbbutton' THEN levelaresponse=0; RUN; /*Creating a variable that says what the correct response was on each trial*/ data Work.JBTData; set Work.JBTData; If correct = 1 then If response='levelabutton' THEN correctresponse='levela'; else correctresponse='levelb'; else If response='levelabutton' THEN correctresponse='levelb'; else correctresponse='levela'; RUN; /*Creating a variable that says what category the stimuli belonged to*/ data Work.JBTData; set Work.JBTData; If trialcode='test_levela_categorya' THEN category='categorya'; If trialcode='test_levela_categoryb' THEN category='categoryb'; If trialcode='test_levelb_categorya' THEN category='categorya'; If trialcode='test_levelb_categoryb' THEN category='categoryb'; RUN; /*Saving this dataset as the raw data*/ data "Q:\KLIFF Personnel\Joey\JBTRawData"; set Work.JBTData; RUN; /*Aggregating for each participant by category and level*/ PROC MEANS DATA=Work.JBTData NWAY ; CLASS subject category correctresponse; VAR levelaresponse correct; OUTPUT OUT=Work.JBTData MEAN=levelaresponse_mean correct_mean; RUN; /*Drop TYPE and FREQ variables generated by SAS*/ data Work.JBTData; set Work.JBTData; keep subject category correctresponse levelaresponse_mean correct_mean; RUN; /*Re-structuring the data to go from tall to wide through two steps then a merge*/ proc transpose data=Work.JBTData out=Work.JBTDataA prefix=levaresp_mean; by subject; id category correctresponse; var levelaresponse_mean; run; proc transpose data=Work.JBTData out=Work.JBTDataB prefix=correct_mean; by subject; id category correctresponse; var correct_mean; run; data Work.JBTData; merge Work.JBTDataA(drop=_name_) Work.JBTDataB(drop=_name_); by subject; run; /*** Creating a Level A Response Rate variable. This may be useful to screen out participants who do not follow study instructions, such as by accepting too many or too few applicants. *** For example, Axt, Nguyen & Nosek (2016) excluded participants who accepted less than 20% and more than 80% of the applicants. *** Also creating a LevelA response rate for each category. This may be useful to exclude participants who gave the same response to all members of one category (for example, accepting or rejecting all cats and dogs). *** In Axt, Nguyen & Nosek (2016), participants were also excluded for accepting or rejecting all members of either category.*/ data Work.JBTData; set Work.JBTData; LevelAResponseRate = (levaresp_meancategoryalevela + levaresp_meancategoryalevelb + levaresp_meancategoryblevela + levaresp_meancategoryblevelb)/4; LevelAResponseRateCategoryA = (levaresp_meancategoryalevela + levaresp_meancategoryalevelb)/2; LevelAResponseRateCategoryB = (levaresp_meancategoryblevela + levaresp_meancategoryblevelb)/2; run; /*Computing overall accuracy as well as accuracy for each individual category*/ data Work.JBTData; set Work.JBTData; OverallAccuracy = (correct_meancategoryalevela + correct_meancategoryalevelb + correct_meancategoryblevela + correct_meancategoryblevelb)/4; CategoryAAccuracy = (correct_meancategoryalevela + correct_meancategoryalevelb)/2; CategoryBAccuracy = (correct_meancategoryblevela + correct_meancategoryblevelb)/2; run; /**** Computing the Signal Detection components: Sensitivity (d') and criterion (c) *** The first step involves calculating hit rates and false alarm rates for both categories*/ data Work.JBTData; set Work.JBTData; HitRateCategoryA = correct_meancategoryalevela; HitRateCategoryB = correct_meancategoryblevela; FalseAlarmCategoryA = 1 - correct_meancategoryalevelb; FalseAlarmCategoryB = 1 - correct_meancategoryblevelb; run; /**** Note that criterion and sensitivity cannot be calculated when individual cells have 100% or 0% accuracy. *** As a result, 1's and 0's need to be replaced with half of an error. In this case, the total task has 64 trials, meaning each of the four hit and false alarm calculations above depends on 16 trials *** Given this setup, we then replace all 0's with 1/32 (.03125) and all 1's with 31/32 (.96875).*/ data Work.JBTData; set Work.JBTData; IF (HitRateCategoryA >= .99999) THEN HitRateCategoryA = .96875; IF (HitRateCategoryB >= .99999) THEN HitRateCategoryB = .96875; IF (FalseAlarmCategoryA >= .99999) THEN FalseAlarmCategoryA = .96875; IF (FalseAlarmCategoryB >= .99999) THEN FalseAlarmCategoryB = .96875; IF (HitRateCategoryA <= .0001) THEN HitRateCategoryA = .03125; IF (HitRateCategoryB <= .0001) THEN HitRateCategoryB = .03125; IF (FalseAlarmCategoryA <= .0001) THEN FalseAlarmCategoryA = .03125; IF (FalseAlarmCategoryB <= .0001) THEN FalseAlarmCategoryB = .03125; RUN; /*Calculating sensitivity (D) and criterion (C)*/ data Work.JBTData; set Work.JBTData; CategoryAD = PROBIT(HitRateCategoryA) - PROBIT(FalseAlarmCategoryA); CategoryBD = PROBIT(HitRateCategoryB) - PROBIT(FalseAlarmCategoryB); RUN; data Work.JBTData; set Work.JBTData; CategoryAC = -(PROBIT(HitRateCategoryA)+ PROBIT(FalseAlarmCategoryA))/2; CategoryBC = -(PROBIT(HitRateCategoryB) + PROBIT(FalseAlarmCategoryB))/2; RUN; /*Descriptives*/ PROC MEANS DATA = Work.JBTData; var CategoryAD CategoryBD CategoryAC CategoryBC; run; /*Save data*/ data "Q:\KLIFF Personnel\Joey\JBTData"; set Work.JBTData; RUN; /*End of Script*/