SPSS syntax issue... file pathway does not exist?!?

#1
Hi Everyone,

I'm really hoping someone can help me as I'm at a complete loss for what to do...

I'm attempting to use a Fleiss Kappa statistic in version 20 of SPSS however, as it is not currently supported by the platform I am using a well established syntax that I only need to alter slightly to 'tell it' where my file is located and what my variable parameters are. I have done this however, I'm repeatedly met with the following error message underneath the syntax;

27 GET FILE The file does not exist.
236 count This command is not permitted before the beginning of file definition commands.
236 select if This command is not valid before a working file has been defined.
236 matrix GET a working file is requested, but a working file does not exist.


OUTPUT WARNING READS;

GET FILE='C:\Users\Compaq\Desktop\Dissertation\testday\SPSS\penarth1.sav'.

>Error # 61 in column 10. Text: C:\Users\Compaq\Desktop\Dissertation\testday\SPSS\penarth1.sav
>The filename is not valid.
>Execution of this command stops.
set seed=123456 .
preserve.
set printback=off mprint=off.

/* Macro Call Line. */

irr raters=rater1 to rater12/category=4 .

>Error # 100. Command name: count
>This command is not permitted before the beginning of file definition
>commands.
>Execution of this command stops.

>Error # 105. Command name: select if
>This command is not valid before a working file has been defined.
>Execution of this command stops.



However, I have checked the file pathway about 100 times and it is definitely correct. I have attempted to move the file to various hard-drives both internal and external in case one of the disks was corrupt but to no avail... based on this I'm wondering;

1) Has anyone come across this issue before?

2) Does it make a difference is SPSS has been downloaded to disc D: instead of C:?

2) Is the issue likely due to my computer or an error with SPSS v20?

3) Could there be an issue with the syntax being initially developed on an earlier version of SPSS making it incompatible with mine?

4) Is there any way to overcome this issue?



Any help, advice or even a point in the right direction would be appreciated... anything at all, I'm an psychology undergraduate completely out of my depth in the hellish world of Syntax!! Additionally, I apologise in advance if this seems simplistic to you, I have read as much as I can to get me to this point of understanding. However, I either don't understand what is being stated on various websites OR it doesn't answer my question :shakehead.

Thank you in advance! :yup:

Kate
 
#2
If you are absolutely sure that there is no error in the filepath and filename then you should try to open the data file manually through the File->Open->Data menu in SPSS. Once the data file is open, open the syntax file and delete the entire line that begins with GET FILE='.....' and try to run the syntax again. If you encounter further errors post back here with a complete copy of the syntax you're trying to run and any errors encountered.
 
#3
Hi Helicon,

Thank you so much for your response, I very much appreciate it!

The syntax I am running is as follows;

GET FILE='C:\Users\Compaq\Desktop\Dissertation\testday\SPSS files\penarth1.sav'.
set seed=123456 .
preserve.
set printback=off mprint=off.
define irr (raters=!charend('/')/category=!charend('/')).
set mxloops=10000000.
count ms__=!raters (missing).
select if ms__=0.
matrix.
get x /var=!raters.
compute n=nrow(x) .
compute raters=ncol(x) .
compute cat=!category .

compute ratersum=make(nrow(x),cat,0).
loop i=1 to nrow(x).
loop j=1 to ncol(x).
loop k=1 to cat.
do if x(i,j)=k.
compute ratersum(i,k)=ratersum(i,k)+1.
end if.
end loop.
end loop.
end loop.


compute casesum=make(cat,ncol(x),0) .
loop i=1 to nrow(x).
loop j=1 to ncol(x) .
loop k=1 to cat.
do if x(i,j)=k .
compute casesum(k,j)=casesum(k,j)+1.
end if .
end loop.
end loop.
end loop.


compute y=x .
compute rtrcatag=make(cat,ncol(x),0) .
loop i=1 to nrow(x) .
loop j=1 to ncol(x) .
loop k=1 to nrow(y) .
loop l=1 to ncol(y) .
do if i=k .
do if j<>l .
do if x(i,j)=y(k,l) .
loop q=1 to cat.
do if x(i,j)=q.
compute rtrcatag(q,j)=rtrcatag(q,j)+1.
end if .
end loop .
end if .
end if .
end if .
end loop .
end loop .
end loop.
end loop.


compute fpa=mssq(ratersum)/(nrow(ratersum)*raters*(raters-1))-(1/(raters-1)) .
compute fpe=msum((csum(ratersum)/msum(ratersum))&**2) .
compute fk=(fpa-fpe)/(1-fpe) .
do if fk<-1.00 .
compute fk=-1.00 .
end if .
do if fk>1.00 .
compute fk=1.00 .
end if .
compute bsicstat={n,raters,cat,fpa} .
save bsicstat/outfile='bsicstat.sav'
/variables=n,raters,cat,fpa .
compute nm=sqrt(n*raters*(raters-1)) .
compute fkvar1=csum(ratersum)/msum(csum(ratersum)) .
compute fkvar2=1-csum(ratersum)/msum(csum(ratersum)) .
compute fkvar3=1-2*(csum(ratersum)/msum(csum(ratersum))) .
compute fkvar4=fkvar1&*fkvar2.
compute fkvar5=fkvar1&*fkvar2&*fkvar3 .
compute sfkvar1=msum(fkvar4) .
compute sfkvar2=msum(fkvar5) .
compute fkse=(sqrt(2)/(sfkvar1*nm))*(sqrt(sfkvar1**2-sfkvar2)) .
compute fkz=fk/fkse .
compute fkp=1-cdfnorm(fkz) .
compute fkll=fk-1.96*fkse .
compute fkul=fk+1.96*fkse .
do if fkll<-1.00 .
compute fkll=-1.00 .
end if .
do if fkul>1.00 .
compute fkul=1.00 .
end if .
compute fkstat={fk,fkse,fkz,fkp,fkll,fkul} .
save fkstat/outfile='fkstat.sav'
/variables=fk,fkse,fkz,fkp,fkll,fkul .


compute fkqprop=csum(ratersum)/msum(csum(ratersum)) .
compute fkqpa=fkqprop+0.000001 .
compute fkqpa2=csum(ratersum&**2) .
compute fkqpa1=(fkqpa2-n*raters*fkqpa)/(n*raters*(raters-1)*fkqpa) .
compute fkq=(fkqpa1-fkqpa)/(1-fkqpa) .
loop #a=1 to ncol(fkq) .
do if fkq(1,#a)<-1.00 .
compute fkq(1,#a)=-1.00 .
end if .
do if fkq(1,#a)>1.00 .
compute fkq(1,#a)=1.00 .
end if .
end loop .
compute fkqvar1=(1+(2*(raters-1)*(csum(ratersum)/msum(csum(ratersum)))))&**2 .
compute fkqvar2=(2*(raters-1))*fkvar4 .
compute fkqvar3=(n*raters*(raters-1)**2)*fkvar4+.000001 .
compute fkqse=sqrt((fkqvar1+fkqvar2)&/fkqvar3)+.000001 .
compute fkqz=fkq&/fkqse.
compute fkqp=1-cdfnorm(fkqz) .
compute fkqll=fkq-(1.96*fkqse) .
compute fkqul=fkq+(1.96*fkqse) .
loop #b=1 to ncol(fkqll) .
do if fkqll(1,#b)<-1.00 .
compute fkqll(1,#b)=-1.00 .
end if .
end loop .
loop #b=1 to ncol(fkqul) .
do if fkqul(1,#b)>1.00 .
compute fkqul(1,#b)=1.00 .
end if .
end loop .
loop i=1 to ncol(fkqprop) .
do if (fkqprop(i)=0.00) .
compute fkq(i)=-99999) .
compute fkqse(i)=-99999 .
compute fkqz(i)=-99999 .
compute fkqp(i)=-99999 .
compute fkqll(i)=-99999.
compute fkqul(i)=-99999.
end if .
end loop .
compute fkqlbl=(1:cat) .
compute raterlbl=(1:raters) .
compute fkqstat1={fkqlbl;fkq;fkqse;fkqz;fkqp;fkqll;fkqul} .
compute fkqstat=t(fkqstat1) .
save fkqstat/outfile='fkqstat.sav'
/variables=fkqlbl,fkq,fkqse,fkqz,fkqp,fkqll,fkqul .


compute casetbl=t(casesum) .
compute ratertbl=t(rtrcatag) .


print {(casetbl)}
/format="f5.0"
/rlabels='Rater'
/clabels='Category'
/title='Summary Table - Number of Subjects by Rater and Category' .
print {(ratertbl)}
/format="f5.0"
/rlabels='Rater'
/clabels='Category'
/title='Summary Table - Number of Agreements by Rater and Category' .

end matrix.


get file='bsicstat.sav' .
formats n(f8.0)/raters(f8.0)/cat(f8.0)/fpa(f8.5) .
variable labels n 'Number of Items'/cat 'Number of Categories' /raters 'Number of Raters'
/fpa 'Proportion of Rater Agreement' .
report format=list automatic align(center)
/variables=n,cat,raters,fpa
/title "Basic Information" .

get file='fkstat.sav' .
formats fk(f8.5)/fkse(f8.5)/fkz(f8.5)/fkp(f8.5)/fkll(f8.5)/fkul(f8.5) .
variable labels fk 'kappa'/fkse 'Standard Error'/fkz 'z'/fkp 'p'/fkll 'Lower 95% Confidence Limit'/
fkul 'Upper 95% Confidence Limit' .
report format=list automatic align(center)
/variables=fk,fkse,fkz,fkp,fkll,fkul
/title "Empirical Confidence Limits - Overall kappa" .

get file='fkqstat.sav' .
formats fkqlbl(f3.0)/fkq(f8.5)/fkqse(f8.5)/fkqz(f8.5)/fkqp(f8.5)/fkqll(f8.5)/fkqul(f8.5) .
variable labels fkqlbl 'Category'/fkq 'kappa'/fkqse 'Standard Error'/fkqz 'z'/fkqp 'p'/fkqll 'Lower 95% Confidence Limit'
/fkqul 'Upper 95% Confidence Limit' .
report format=list automatic align(center)
/variables=fkqlbl,fkq,fkqse,fkqz,fkqp,fkqll,fkqul
/title "Empirical Confidence Limits - Category kappa" .

!enddefine.
restore.

/* Macro Call Line. */

irr raters=rater1 to rater12/category=4 .


define !dump (vlist=!enclose('(',')')) .
!do !z !in (!vlist) .
erase file=!quote(!concat("c:\program files\spss\",!unquote(!z),".sav")) .
!doend .
!enddefine .
new file .
set mprint=yes .
!dump vlist (bsicstat fkstat fkqstat) .
set mprint=no .


**Please note that the syntax is not of my own design it was kindly (and altruistically) provided to me by a third party, so I can't and wouldn't want to take credit for it!**

Here is the error message I'm getting at the bottom of the syntax;


235 matrix SPSS Statistics cannot access a file with the given file specification. The file specification is either syntactically invalid, specifies an invalid drive, specifies a protected directory, specifies a protected file, or specifies a non-sharable file.
235 get file The filename is not valid.
235 formats A variable named on the FORMATS, PRINT FORMATS, or WRITE FORMATS command has not yet been defined.
235 variable labels An unknown variable name was specified on the VAR LABELS command. The name and the label will be ignored.
235 report A variable on the REPORT VARIABLES subcommand was neither a SPSS Statistics variable, a REPORT STRING variable, or a dummy variable (as designated by the DUMMY option to the subcommand).
235 get file The filename is not valid.
235 formats A variable named on the FORMATS, PRINT FORMATS, or WRITE FORMATS command has not yet been defined.
235 variable labels An unknown variable name was specified on the VAR LABELS command. The name and the label will be ignored.
235 report A variable on the REPORT VARIABLES subcommand was neither a SPSS Statistics variable, a REPORT STRING variable, or a dummy variable (as designated by the DUMMY option to the subcommand).
235 report A variable on the REPORT VARIABLES subcommand was neither a SPSS Statistics variable, a REPORT STRING variable, or a dummy variable (as designated by the DUMMY option to the subcommand).
235 report A variable on the REPORT VARIABLES subcommand was neither a SPSS Statistics variable, a REPORT STRING variable, or a dummy variable (as designated by the DUMMY option to the subcommand).
235 report A variable on the REPORT VARIABLES subcommand was neither a SPSS Statistics variable, a REPORT STRING variable, or a dummy variable (as designated by the DUMMY option to the subcommand).
235 report A variable on the REPORT VARIABLES subcommand was neither a SPSS Statistics variable, a REPORT STRING variable, or a dummy variable (as designated by the DUMMY option to the subcommand).
235 report A variable on the REPORT VARIABLES subcommand was neither a SPSS Statistics variable, a REPORT STRING variable, or a dummy variable (as designated by the DUMMY option to the subcommand).
235 get file The filename is not valid.
235 formats A variable named on the FORMATS, PRINT FORMATS, or WRITE FORMATS command has not yet been defined.
235 variable labels An unknown variable name was specified on the VAR LABELS command. The name and the label will be ignored.
235 variable labels An unknown variable name was specified on the VAR LABELS command. The name and the label will be ignored.
235 variable labels An unknown variable name was specified on the VAR LABELS command. The name and the label will be ignored.
235 variable labels An unknown variable name was specified on the VAR LABELS command. The name and the label will be ignored.
235 variable labels An unknown variable name was specified on the VAR LABELS command. The name and the label will be ignored.
235 variable labels An unknown variable name was specified on the VAR LABELS command. The name and the label will be ignored.
235 variable labels An unknown variable name was specified on the VAR LABELS command. The name and the label will be ignored.
235 report A variable on the REPORT VARIABLES subcommand was neither a SPSS Statistics variable, a REPORT STRING variable, or a dummy variable (as designated by the DUMMY option to the subcommand).
246 erase The specified file does not exist and cannot be erased.


There were many more of these errors however, they were duplicates of the above. Couldn't post them all as I was given a character limit warning.

Although, it is a standard one-size fits all syntax, I was given explicit instructions as to the sections that need changing to fit my parameters. This I have done. I just can't get it to work for some reason.

Thank you again :)

Kate
 
#4
My guess is the root cause of your problems is a lack of read/write permissions to the file/directories that SPSS is trying to use. There is nothing wrong with the syntax (I tested it on some dummy data) - the issue is definitely on your end.

I've made some very minor modifications to the syntax to create a temporary working directory on your desktop (using the path specified in your first post 'C:\Users\Compaq\Desktop\') and to execute all write and read operations from that directory. If this isn't a valid file path or you don't have the required permissions then it won't work. Assuming everything is ok, please do the following:

1. Open your datafile manually using File -> Open -> Data (variables should be named rater1 to rater12 with 4 categories as specified where the macro is called).
2. Open a new syntax winow.
3. Paste the following into the syntax window, cross your fingers, and run it.

Code:
host command =['if not exist C:\Users\Compaq\Desktop\tempdata md C:\Users\Compaq\Desktop\tempdata'].

file handle tempdata /name = 'C:\Users\Compaq\Desktop\tempdata'.

set seed=123456 .
preserve.
set printback=off mprint=off.
define irr (raters=!charend('/')/category=!charend('/')).
set mxloops=10000000.
count ms__=!raters (missing).
select if ms__=0.
matrix.
get x /var=!raters.
compute n=nrow(x) .
compute raters=ncol(x) .
compute cat=!category .

compute ratersum=make(nrow(x),cat,0).
loop i=1 to nrow(x).
loop j=1 to ncol(x).
loop k=1 to cat.
do if x(i,j)=k.
compute ratersum(i,k)=ratersum(i,k)+1.
end if.
end loop.
end loop.
end loop.



compute casesum=make(cat,ncol(x),0) .
loop i=1 to nrow(x).
loop j=1 to ncol(x) .
loop k=1 to cat.
do if x(i,j)=k .
compute casesum(k,j)=casesum(k,j)+1.
end if .
end loop.
end loop.
end loop.


compute y=x .
compute rtrcatag=make(cat,ncol(x),0) .
loop i=1 to nrow(x) .
loop j=1 to ncol(x) .
loop k=1 to nrow(y) .
loop l=1 to ncol(y) .
do if i=k .
do if j<>l .
do if x(i,j)=y(k,l) .
loop q=1 to cat.
do if x(i,j)=q.
compute rtrcatag(q,j)=rtrcatag(q,j)+1.
end if .
end loop .
end if .
end if .
end if .
end loop .
end loop .
end loop.
end loop.


compute fpa=mssq(ratersum)/(nrow(ratersum)*raters*(raters-1))-(1/(raters-1)) .
compute fpe=msum((csum(ratersum)/msum(ratersum))&**2) .
compute fk=(fpa-fpe)/(1-fpe) .
do if fk<-1.00 .
compute fk=-1.00 .
end if .
do if fk>1.00 .
compute fk=1.00 .
end if .
compute bsicstat={n,raters,cat,fpa} .
save bsicstat/outfile='tempdata\bsicstat.sav'
/variables=n,raters,cat,fpa .
compute nm=sqrt(n*raters*(raters-1)) .
compute fkvar1=csum(ratersum)/msum(csum(ratersum)) .
compute fkvar2=1-csum(ratersum)/msum(csum(ratersum)) .
compute fkvar3=1-2*(csum(ratersum)/msum(csum(ratersum))) .
compute fkvar4=fkvar1&*fkvar2.
compute fkvar5=fkvar1&*fkvar2&*fkvar3 .
compute sfkvar1=msum(fkvar4) .
compute sfkvar2=msum(fkvar5) .
compute fkse=(sqrt(2)/(sfkvar1*nm))*(sqrt(sfkvar1**2-sfkvar2)) .
compute fkz=fk/fkse .
compute fkp=1-cdfnorm(fkz) .
compute fkll=fk-1.96*fkse .
compute fkul=fk+1.96*fkse .
do if fkll<-1.00 .
compute fkll=-1.00 .
end if .
do if fkul>1.00 .
compute fkul=1.00 .
end if .
compute fkstat={fk,fkse,fkz,fkp,fkll,fkul} .
save fkstat/outfile='tempdata\fkstat.sav'
/variables=fk,fkse,fkz,fkp,fkll,fkul .


compute fkqprop=csum(ratersum)/msum(csum(ratersum)) .
compute fkqpa=fkqprop+0.000001 .
compute fkqpa2=csum(ratersum&**2) .
compute fkqpa1=(fkqpa2-n*raters*fkqpa)/(n*raters*(raters-1)*fkqpa) .
compute fkq=(fkqpa1-fkqpa)/(1-fkqpa) .
loop #a=1 to ncol(fkq) .
do if fkq(1,#a)<-1.00 .
compute fkq(1,#a)=-1.00 .
end if .
do if fkq(1,#a)>1.00 .
compute fkq(1,#a)=1.00 .
end if .
end loop .
compute fkqvar1=(1+(2*(raters-1)*(csum(ratersum)/msum(csum(ratersum)))))&**2 .
compute fkqvar2=(2*(raters-1))*fkvar4 .
compute fkqvar3=(n*raters*(raters-1)**2)*fkvar4+.000001 .
compute fkqse=sqrt((fkqvar1+fkqvar2)&/fkqvar3)+.000001 .
compute fkqz=fkq&/fkqse.
compute fkqp=1-cdfnorm(fkqz) .
compute fkqll=fkq-(1.96*fkqse) .
compute fkqul=fkq+(1.96*fkqse) .
loop #b=1 to ncol(fkqll) .
do if fkqll(1,#b)<-1.00 .
compute fkqll(1,#b)=-1.00 .
end if .
end loop .
loop #b=1 to ncol(fkqul) .
do if fkqul(1,#b)>1.00 .
compute fkqul(1,#b)=1.00 .
end if .
end loop .
loop i=1 to ncol(fkqprop) .
do if (fkqprop(i)=0.00) .
compute fkq(i)=-99999) .
compute fkqse(i)=-99999 .
compute fkqz(i)=-99999 .
compute fkqp(i)=-99999 .
compute fkqll(i)=-99999.
compute fkqul(i)=-99999.
end if .
end loop .
compute fkqlbl=(1:cat) .
compute raterlbl=(1:raters) .
compute fkqstat1={fkqlbl;fkq;fkqse;fkqz;fkqp;fkqll;fkqul} .
compute fkqstat=t(fkqstat1) .
save fkqstat/outfile='tempdata\fkqstat.sav'
/variables=fkqlbl,fkq,fkqse,fkqz,fkqp,fkqll,fkqul .


compute casetbl=t(casesum) .
compute ratertbl=t(rtrcatag) .


print {(casetbl)}
/format="f5.0"
/rlabels='Rater'
/clabels='Category'
/title='Summary Table - Number of Subjects by Rater and Category' .
print {(ratertbl)}
/format="f5.0"
/rlabels='Rater'
/clabels='Category'
/title='Summary Table - Number of Agreements by Rater and Category' .

end matrix.


get file='tempdata\bsicstat.sav' .
formats n(f8.0)/raters(f8.0)/cat(f8.0)/fpa(f8.5) .
variable labels n 'Number of Items'/cat 'Number of Categories' /raters 'Number of Raters'
/fpa 'Proportion of Rater Agreement' .
report format=list automatic align(center)
/variables=n,cat,raters,fpa
/title "Basic Information" .

get file='tempdata\fkstat.sav' .
formats fk(f8.5)/fkse(f8.5)/fkz(f8.5)/fkp(f8.5)/fkll(f8.5)/fkul(f8.5) .
variable labels fk 'kappa'/fkse 'Standard Error'/fkz 'z'/fkp 'p'/fkll 'Lower 95% Confidence Limit'/
fkul 'Upper 95% Confidence Limit' .
report format=list automatic align(center)
/variables=fk,fkse,fkz,fkp,fkll,fkul
/title "Empirical Confidence Limits - Overall kappa" .

get file='tempdata\fkqstat.sav' .
formats fkqlbl(f3.0)/fkq(f8.5)/fkqse(f8.5)/fkqz(f8.5)/fkqp(f8.5)/fkqll(f8.5)/fkqul(f8.5) .
variable labels fkqlbl 'Category'/fkq 'kappa'/fkqse 'Standard Error'/fkqz 'z'/fkqp 'p'/fkqll 'Lower 95% Confidence Limit'
/fkqul 'Upper 95% Confidence Limit' .
report format=list automatic align(center)
/variables=fkqlbl,fkq,fkqse,fkqz,fkqp,fkqll,fkqul
/title "Empirical Confidence Limits - Category kappa" .

!enddefine.
restore.

/* Macro Call Line.	 */

irr raters=rater1 to rater12/category=4 .


define !dump (vlist=!enclose('(',')')) .
!do !z !in (!vlist) .
erase file=!quote(!concat("tempdata\",!unquote(!z),".sav")) .
!doend .
!enddefine .
new file .
set mprint=yes .
!dump vlist (bsicstat fkstat fkqstat) .
set mprint=no .
 
#5
THANK YOU HELICON:yup::yup::yup:

After spending so very, very long staring at error messages I finally have my data!!!!

I really appreciate all your help, more than you can possibly know!

Kate