dnl PSPP - a program for statistical analysis. dnl Copyright (C) 2017 Free Software Foundation, Inc. dnl dnl This program is free software: you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation, either version 3 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program. If not, see . dnl AT_BANNER([AUTORECODE procedure]) AT_SETUP([AUTORECODE multiple missing values]) AT_DATA([autorecode.sps], [DATA LIST LIST NOTABLE /u v w x y z (F2.0). BEGIN DATA. 11 11 11 11 11 11 12 12 12 12 12 12 13 13 13 13 13 13 14 14 14 14 14 14 15 15 15 15 15 15 16 16 16 16 16 16 END DATA. MISSING VALUES u (11) v (11, 12) w (11, 12, 13) x (11 THRU 14) y (11 THRU 15) z (11 THRU 16). AUTORECODE u v w x y z INTO a b c d e f. LIST. DISPLAY VARIABLES/VARIABLES=a TO f. ]) AT_CHECK([pspp -O format=csv autorecode.sps], [0], [dnl Table: Data List u,v,w,x,y,z,a,b,c,d,e,f 11,11,11,11,11,11,6.00,5.00,4.00,3.00,2.00,1.00 12,12,12,12,12,12,1.00,6.00,5.00,4.00,3.00,2.00 13,13,13,13,13,13,2.00,1.00,6.00,5.00,4.00,3.00 14,14,14,14,14,14,3.00,2.00,1.00,6.00,5.00,4.00 15,15,15,15,15,15,4.00,3.00,2.00,1.00,6.00,5.00 16,16,16,16,16,16,5.00,4.00,3.00,2.00,1.00,6.00 Table: Variables Name,Position,Print Format,Write Format,Missing Values a,7,F8.2,F8.2,6 b,8,F8.2,F8.2,5; 6 c,9,F8.2,F8.2,4; 5; 6 d,10,F8.2,F8.2,3 THRU 6 e,11,F8.2,F8.2,2 THRU 6 f,12,F8.2,F8.2,1 THRU 6 ]) AT_CLEANUP AT_SETUP([AUTORECODE numbers and short strings]) AT_DATA([autorecode.sps], [data list /X 1-5(a) Y 7. begin data. lasdj 1 asdfk 0 asdfj 2 asdfj 1 asdfk 2 asdfj 9 lajks 9 asdfk 0 asdfk 1 end data. missing values x('asdfk') y(9). autorecode x y into A B/descend. list. compute Z=trunc(y/2). autorecode z into W. list. ]) AT_CHECK([pspp -O format=csv autorecode.sps], [0], [Table: Reading 1 record from INLINE. Variable,Record,Columns,Format X,1,1- 5,A5 Y,1,7- 7,F1.0 Table: Data List X,Y,A,B lasdj,1,1.00,2.00 asdfk,0,4.00,3.00 asdfj,2,3.00,1.00 asdfj,1,3.00,2.00 asdfk,2,4.00,1.00 asdfj,9,3.00,4.00 lajks,9,2.00,4.00 asdfk,0,4.00,3.00 asdfk,1,4.00,2.00 Table: Data List X,Y,A,B,Z,W lasdj,1,1.00,2.00,.00,1.00 asdfk,0,4.00,3.00,.00,1.00 asdfj,2,3.00,1.00,1.00,2.00 asdfj,1,3.00,2.00,.00,1.00 asdfk,2,4.00,1.00,1.00,2.00 asdfj,9,3.00,4.00,. ,. @&t@ lajks,9,2.00,4.00,. ,. @&t@ asdfk,0,4.00,3.00,.00,1.00 asdfk,1,4.00,2.00,.00,1.00 ]) AT_CLEANUP AT_SETUP([AUTORECODE long strings and check the value labels]) AT_DATA([ar.sps], [data list notable list /s (a16) x *. begin data. widgets 1 thingummies 2 oojars 3 widgets 4 oojars 5 thingummies 6 oojimiflips 7 end data. value labels /s 'thingummies' 'Funny sticky things'. autorecode s into new. list. display dictionary/variables=new. ]) AT_CHECK([pspp -O format=csv ar.sps], [0], [Table: Data List s,x,new widgets,1.00,4.00 thingummies,2.00,3.00 oojars,3.00,1.00 widgets,4.00,4.00 oojars,5.00,1.00 thingummies,6.00,3.00 oojimiflips,7.00,2.00 Table: Variables Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values new,3,,Scale,Input,8,Right,F8.2,F8.2, Table: Value Labels Variable Value,,Label new,1.00,oojars ,2.00,oojimiflips ,3.00,Funny sticky things ,4.00,widgets ]) AT_CLEANUP AT_SETUP([AUTORECODE group subcommand]) AT_DATA([ar-group.sps], [data list notable list /x * y *. begin data. 11 10 12 12 13 15 14 11 15 12 16 18 end data. missing values y (12). autorecode x y into a b /group. list. display variables /variables=a b. ]) AT_CHECK([pspp -O format=csv ar-group.sps], [0], [Table: Data List x,y,a,b 11.00,10.00,2.00,1.00 12.00,12.00,8.00,8.00 13.00,15.00,3.00,5.00 14.00,11.00,4.00,2.00 15.00,12.00,5.00,8.00 16.00,18.00,6.00,7.00 Table: Variables Name,Position,Print Format,Write Format,Missing Values a,3,F8.2,F8.2,8 b,4,F8.2,F8.2,8 ]) AT_CLEANUP AT_SETUP([AUTORECODE group - string variables]) AT_DATA([strings.sps], [data list notable list /x (a8) y (a16). begin data. fred bert charlie " " delta echo " " windows " " nothing end data. autorecode x y into a b /group. delete variables x y. list. ]) AT_CHECK([pspp -O format=csv strings.sps], [0], [Table: Data List a,b 6.00,2.00 3.00,1.00 4.00,5.00 1.00,8.00 1.00,7.00 ]) AT_CLEANUP dnl Tests for a crash which happened when the /GROUP subcommand dnl appeared with string variables of different widths. AT_SETUP([AUTORECODE group vs. strings]) AT_DATA([ar-strings.sps], [data list notable list /a (a12) b (a6). begin data. one nine two ten three eleven four nought end data. autorecode a b into x y /group. list. ]) AT_CHECK([pspp -O format=csv ar-strings.sps], [0], [dnl Table: Data List a,b,x,y one,nine,5.00,3.00 two,ten,8.00,6.00 three,eleven,7.00,1.00 four,nought,2.00,4.00 ]) AT_CLEANUP AT_SETUP([AUTORECODE /blank]) AT_DATA([auto-blank.sps], [dnl data list notable list /x (a8) y * z (a16). begin data. one 2 fred two 4 "" "" 4 fred "" 2 charliebrown three 2 charliebrown end data. autorecode variables x y z into a b c /blank=missing. list a b c y. ]) AT_CHECK([pspp -O format=csv auto-blank.sps], [0], [dnl Table: Data List a,b,c,y 1.00,1.00,2.00,2.00 3.00,2.00,. ,4.00 . ,2.00,2.00,4.00 . ,1.00,1.00,2.00 2.00,1.00,1.00,2.00 ]) AT_CLEANUP dnl AUTORECODE had a use-after-free error when TEMPORARY was in use. dnl Bug #32757. AT_SETUP([AUTORECODE with TEMPORARY]) AT_DATA([autorecode.sps], [data list /X 1-5(a) Y 7. begin data. lasdj 1 asdfk 0 asdfj 2 asdfj 1 asdfk 2 asdfj 9 lajks 9 asdfk 0 asdfk 1 end data. temporary. select if y > 1. autorecode x y into A B/descend. list. ]) AT_CHECK([pspp -O format=csv autorecode.sps], [0], [Table: Reading 1 record from INLINE. Variable,Record,Columns,Format X,1,1- 5,A5 Y,1,7- 7,F1.0 Table: Data List X,Y,A,B lasdj,1,. ,. @&t@ asdfk,0,2.00,. @&t@ asdfj,2,3.00,2.00 asdfj,1,3.00,. @&t@ asdfk,2,2.00,2.00 asdfj,9,3.00,1.00 lajks,9,1.00,1.00 asdfk,0,2.00,. @&t@ asdfk,1,2.00,. @&t@ ]) AT_CLEANUP dnl For compatibility, make sure that /INTO (with leading slash) is accepted dnl (bug #48762) AT_SETUP([AUTORECODE with /INTO]) AT_DATA([autorecode.sps], [data list list notable /x . begin data. 1 8 -901 4 1 99 8 end data. autorecode x /into y. list. ]) AT_CHECK([pspp -O format=csv autorecode.sps], [0], [Table: Data List x,y 1.00,2.00 8.00,4.00 -901.00,1.00 4.00,3.00 1.00,2.00 99.00,5.00 8.00,4.00 ]) AT_CLEANUP