quantum section wise

19
Introduction Back to top All quantum editing is put in the edit section of the run file, i.e. ed [in here] end You can type directly into the run file but it's a good idea to put different types of edits into different files and "*include" them. eg: ed *include correct *include force *include clean end The files should be included in this order so that the edit corrections are applied to the data before any force edits are applied and then the forces are applied before the cleaning checks. 1. "Clean" File Back to top Data Validation Single punch edits (Red spined manual - Editing data in quantum, chapter 3) All variables/ questions that should be single coded should be edited using the r (require) statement. You can enclose text after the edit instruction in dollar signs which will appear in the out2 and make the errors more understandable (especially if you are going to send the out2 to the researcher to send back corrections). Examples Checking one column - must be single code r sp c112'12'o $c112 single code 1/2 only$ r sp c118 $c118 single code$ [if can be any code no need to say c118'1/90-&']

Upload: noor-basha

Post on 02-Dec-2014

135 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Quantum Section Wise

Introduction

Back to top

All quantum editing is put in the edit section of the run file, i.e.

ed[in here]end

You can type directly into the run file but it's a good idea to put different types of edits into different files and "*include" them.

eg:

ed*include correct*include force*include cleanend

The files should be included in this order so that the edit corrections are applied to the data before any force edits are applied and then the forces are applied before the cleaning checks.

 

1. "Clean" File

Back to top

Data Validation

Single punch edits (Red spined manual - Editing data in quantum, chapter 3)

All variables/ questions that should be single coded should be edited using the r (require) statement. You can enclose text after the edit instruction in dollar signs which will appear in the out2 and make the errors more understandable (especially if you are going to send the out2 to the researcher to send back corrections).

Examples

Checking one column - must be single coder sp c112'12'o $c112 single code 1/2 only$r sp c118 $c118 single code$ [if can be any code no need to say c118'1/90-&']

Checking one column - must be single code or blankr spb c112'12'o $c112 single code 1/2 only$r spb c118 $c118 single code$ [if can be any code no need to say c118'1/90-&']

Checking for single punch where question spans 2+ columnsr (numb(c114,c115).eq.(1)) [this will flag blanks as errors]or

Page 2: Quantum Section Wise

r (numb(c114,c115).le.(1)) [this will allow blanks through]

Checking for single punch where question spans 2+ columns - only codes 1-5 valid on c115r (numb(c114,c115'1/5').eq.(1)) [this will flag blanks as errors]orr (numb(c114,c115'1/5').le.(1)) [this will allow blanks through]

Checking column not blankr nb c114

Checking column blankr b c114

Checking for valid data in an array of 2+ columns, eg month on columns 120-121

r (range,120,121,1,12)ORr (c(120,121).in.(01:12))

All edit failures will be listed in file out2.

Include this line in your edit section in the run file

filedef out2 print mpd

- then any multi punches will be legibly listed vertically in the out2 file (try it and you'll see), otherwise you just get a *.

 

2. "Force" File

Back to top

Data Editing

We can apply logical forces to our data so it covers up for where the respondent didn't answer in a logical way. Two examples are shown below.

Spontaneous/unaided awareness

Recoding for example first and other mentions at spontaneous/unaided awarenessto create total mentions.

First mention c132 all codesOther mentions c133 all codes

2 options:a) If only first and total mentions required (check with researcher)code first into other as follows

Page 3: Quantum Section Wise

c133=OR(c132,c133)

b) If other mentions needs to be kept discreet (check with researcher)code first and other out to an unused column eg one from 81-99

c181=OR(c132,c133)

Now you have 1st on c132, other on c133 and total on c181.In this case we need to delete from other mentions those mentioned at first mention, so that first and other are discreet.We can do this in a do-loop:

do 1 'p'='1','&',if (c132'p') delete c133'p'1 continue

We also need to clear anyone out of DK who has mentioned anything, so if Don't Know is & we can do this clean:

if (c132'1/0-') delete c132'&'if (c133'1/0-') delete c133'&'if (c181'1/0-') delete c181'&'

Usage gridIf you have a usage grid with the following sub-questions you might want to apply a few logical edits.

Heard of (prompted awareness) c140Ever bought c141Buy nowadays c142Buy most often c143

Force "Buy Most Often" into "Buy Nowadays"c142=OR(c142,c143)Force "Buy Now" into "Ever bought"c141=OR(c141,c142)Force "Ever bought into "Heard Of"c140=OR(c140,c141)

Do the edits in the above order so that buy most often is forced all the way across to heard of.

 

3. "Correct" File

Back to top

Data correction

Edit corrections are done in a similar way to Merlin, ie on the basis of the serial/id number.

Page 4: Quantum Section Wise

Common correctional commands are set, emit, delete, and clear.

Set: Overwrites what is already in the column(s). This is the default so if you want to do this the word set may be omitted.

Emit: Appends to what is already in the column(s)

Delete: Deletes specified codes(s) from the column(s)

Clear: Clears all codes out of the column(s)

eg: (assume serial number on cols 5-8)if (c(105,108).in.(126)) c112'1'if (c(105,108).in.(129)) delete c116'4'if (c(105,108).in.(130)) delete c118'56'if (c(105,108).in.(131)) clear c120if (c(105,108).in.(134)) emit c114'4'

The operator ".in." is an alternative to using the following construction.if (c(105,108)=$0126$) c112'1'

The advantage of ".in." is that it will recognise 126, 0126 and blank 126 in the same way whereas the =$$ is a literal string. So ".in." is safer.

".in." can also be used for dealing with numeric information, whether in edits or in axes. Other arithmetic operators which can be used in a similar way are

.eq. is equal to

.ge. is greater than or equal to

.gt. is greater than

.le. is less than or equal to

.lt. is less than

.ne. is not equal to

 

If you need to rename a string ".eq.(****)" will only work in the condition part of the statement.to set the new one you must use =$***$

For example recoding the sampling point by questionairre no.

if(c(109,112).in.(0472,0475,0476,1035)) c(360,364).eq.(12043) will not work!

Howeverif(c(109,112).in.(0472,0475,0476,1035)) c(360,364)=$12043$ will work.

 

 

Page 5: Quantum Section Wise

4. Weighting

Back to top

There are two basic forms of weighting: -

1) Factor weightingThis is where the data is weighted by a factor that is contained within the datafile, for example on omnibus and catibus our analysis is standardly weighted by a factor.

omnibus weight matrix

wm1 axdum pre=cx(9911,9915);factor;1

You need an axis in your axis file like this, which is just a dummy to make the weighting work.

l axdumn01

On your a-statement (table formats) you need to change wm=0 to wm=1, and you need to show unweighted base, weighted base and effective sample size in your tables. (See layout files below).

2) Rim weightingHere we supply the target percentages or absolutes and quantum calculates the necessary factor for each respondent so that each cell comes out as we want it. Say we want, in a sample of 400 to weight age and sex as follows:

Male 180Female 220

15-24 5025-34 8035-49 9050-64 10065+ 80

We create a file called wmaxis and create these variables, (common demographic variables can often be copied from the banner file).

l wsexn01MALE;c=c112'1'n01FEMALE;c=c112'2'

l wagen0115-24;c=c119'1/4'n0125-34;c=c119'56'n0135-44;c=c119'78'n0145-54;c=c119'9'.or.c120'1'n0155-64;c=c120'23'n0165+ ;c=c120'4'

Page 6: Quantum Section Wise

and remember to add the line *include wmaxis at the bottom of your run file.

your weight matrix will look like this

wm1 wsex wage;rim+180;220+50;80;90;100;80

make the same amendments to your a statement and your bases as with factor weighting.

If you want to use percentages instead of absolutes, use the keyword "input" and supply the percentages as specified by the researcher.

eg:wm1 wsex wage;rim;input+40;60+22;33;20;15;10

If you want to gross your base up to some universe, eg a population universe, use the keyword total, so to gross up to 500,000 our matrix above becomes

eg:wm1 wsex wage;rim;input;total=500000+40;60+22;33;20;15;10

 

5. "Sorting\Ranking" Tables

Back to top

(p97 Quantum Foundation Skills (Yellow))

This is done very easily in quantum, you just put the keyword sort, usually on the axis label as follows.

l q1;sort

The opposite is "nosort" which should be put on your "Other" and your "Don't Know/Not stated" responses

n01Don't Know;c=c256'&';nosortn01Not Stated;c=-;nosort

If you have used a col, val or fld rather than n01's use %nosort, just as you would use %nofac where you have mean scores on one of these

 

 

 

Page 7: Quantum Section Wise

6. Creating sets of variables e.g Breakout of Grid

Back to top

Whereas in Merlin you might use do-loops to create repeat variables, in Quantum do-loops are used in the edit section only.

In Quantum the most efficient way to create these variables is by using a .qin file which has all the common text required. We use text substitution and column substitution to define what differs for each variable, and *include the qin file in the axis file for each variable.

the .qin file may look like this

l q1&qnottl Q.1 IMPORTANCE OF FACTORS IN CHOOSING HOLIDAY DESTINATION: &stmtn23 Q.1 &stmt;norowttl Based on all respondents&layoutcol a00+(10)10 - Extremely Important=0;%fac=10;%norow+(9) 9=9 ;%fac=9;%norow+(8) 8=8 ;%fac=8;%norow+(7) 7=7 ;%fac=7;%norow+(6) 6=6 ;%fac=6;%norow+(5) 5 - Neither=5;%fac=5;%norow+(4) 4=4 ;%fac=4;%norow+(3) 3=3 ;%fac=3;%norow+(2) 2=2 ;%fac=2;%norow+(1) 1 - Not at all Important=1 ;%fac=1;%norow+DK/NS=rej;%norown018-10;c=ca00'890'n015-7;c=ca00'5/7'n011-4;c=ca00'1/4'n01DK/NS;c=-3&mean

this file can be called q1.qin, and then in the axis file way have:

*include q1.qin;stmt=Competitively priced access transport;col(a)=123;qno=a*include q1.qin;stmt=Easy to get to;col(a)=124;qno=b*include q1.qin;stmt=A range of good quality accommodation;col(a)=125;qno=c*include q1.qin;stmt=Reasonably priced accommodation;col(a)=126;qno=d*include q1.qin;stmt=Good food and opportunities for eating out;col(a)=127;qno=e*include q1.qin;stmt=Cost of car hire is competitive;col(a)=128;qno=f*include q1.qin;stmt=Beautiful scenery;col(a)=129;qno=g*include q1.qin;stmt=Natural unspoilt environment;col(a)=130;qno=h*include q1.qin;stmt=Friendly hospitable people;col(a)=131;qno=i*include q1.qin;stmt=Easy and relaxed pace of life;col(a)=132;qno=j

then to tabulate these we might have in the tables file

tab q1a top1tab q1b top1tab q1c top1tab q1d top1tab q1e top1tab q1f top1

Page 8: Quantum Section Wise

tab q1g top1tab q1h top1tab q1i top1tab q1j top1

 

 

 

7. Template Files

Back to top

To create your set-ups more efficiently and to achieve more standardised tables, use the following templates, which are consistent with what the UK do. These will be put into the run files already used for omnibus and syndicate. Below is an explanation of what each means.

/* for unwtd#def layout=*include X:\quantum\template\layoutuw

/* for wtdC#def layout=*include X:\quantum\template\layoutw

The two layouts are used instead of n10Total and provide weighted/unweighted bases as appropriate, comment in/out depending on whether you are weighting the data. In your axes use this:

l q6b;c=c163'1'ttl Q.6b HOW TOURED BY CAR DURING HOLIDAYn23 Q.6b HOW TOURED BY CAR DURING HOLIDAY;norowttl Based on all who toured by car&layoutn01Your own car;c=c164'3'n01A borrowed car;c=c164'4'n01A hired car;c=-

instead of:

l q6b;c=c163'1'ttl Q.6b HOW TOURED BY CAR DURING HOLIDAYn23 Q.6b HOW TOURED BY CAR DURING HOLIDAY;norowttl Based on all who toured by carn10Totaln01Your own car;c=c164'3'n01A borrowed car;c=c164'4'n01A hired car;c=-

The advantage of this is that when you weight the data all you need to amend is the "#def layout".#def sigma=*include X:\quantum\template\sigma

This gives you a sum of all responses and can be used to check a single code question adds to 100%, for

Page 9: Quantum Section Wise

example. If you want to use it you just add the line &sigma at the end of your axis, as follows:

l q11b;c=c240'1'ttl Q.11b SATISFACTION WITH QUALITY OF INFORMATION RECEIVED FROM TIOn23 Q.11b SATISFACTION WITH QUALITY OF INFORMATION RECEIVED FROM TIO;norowttl Based on all used tourist information office&layoutn01(2) Very Satisfied;c=c241'1';fac=2n01(1) Fairly Satisfied;c=c241'2';fac=1n01(0) Not Satisfied;c=c241'3';fac=0n01Don't Know;c=-&mean&sigma

#def mean=*include X:\quantum\template\mean

[ This adds in a mean, a standard deviation and a standard error, this is what the UK standardly produce - we will review to see if we should add in error variance as it is on merlin tables as standard. Its use is shown in the &sigma example above. It means only one line is needed and you don't need to remember n12/n17/n19 etc.]

/* amend columns#def DATE=c(125,132)#def WEEK=c(1369,1374)[ These are only really used on Qdent studies. ]

C used when tables to be sorted/ranked*def SRT=sortC used when checking tablesC*def SRT=nosortThese are to quickly alternate between sorting/ranking and not sorting/ ranking. If you have an axis that needs to be ranked but you want it unranked to check it, use this construction:

l q2;&SRT

and comment in the relevant "*def SRT".

 

 

 

8. Managing multiple table runs

Back to top

A good practice to adopt if you have lots of table runs is to keep tab and table files consistent.One way is to call your "tabs" file for your main run "main.tab" instead of "tabs".

Instead of "quantum run data" type "quantum run data main.rpt" and convert main.rpt in Word to main.doc.

Page 10: Quantum Section Wise

Then for subsequent runs use

extra1.tab (extra1.rpt)extra2.tab (extra2.rpt)

etc..

In this way your table runs will never be overwritten - a tab_ would be overwritten by any subsequent run.

 

 

 

9. Running SPSS data

Back to top

A) Copy your tabs file and Save As tabsspssRemove/comment out all Summary Grids + Analysis of SampleVariable names must be a length of 5 or less

B) Copy your banner file and Save As banspss Remove ALL crossbreaks and replace with :l top1n10Total

C) Edit your run file to reference tabsspss + banspss

D) Run your Quantum tabs [Quantum run data]

E) Next, at the DOS prompt, type [nqtspss -q=100 -r=60 ]

- Send the two files created to stats: Data.qsp (data file) + Commands.qsp (descriptor file)...along with a set of unweighted tables.

---------------------------------------------------------------INCLUDING RESPONDENT NUMBER IN SPSS DATA---------------------------------------------------------------

In run file at top before edit section

int respno 1

edrespno=c(104,107)end

tab tot tot;inc=respno;inctext=RESPONDENT NUMBER

 

Page 11: Quantum Section Wise

10. Creating a new recoded datafile

Back to top

There are various situations where you might want to create a new datafile.

- On a data only job you will need this to create the file for the client.- On a continuous study you might want to create a datafile that incorporates all the cleaning for that round, and maybe also has a weighting factor included.- You might have a booster where the columns and codes match the main section but it is on a different card.

For this you just need a skeleton run file with just a struct statement and an edit section.

eg:struct;read=2;ser=c(4,7);crd=c(8,9);max=99

ed

end

You don't need any axes, banners or tables.

Then insert your edit files (if any)

struct;read=2;ser=c(4,7);crd=c(8,9);max=99

ed

*include correct*include force*include clean

/* file below recodes data, possibly to a client map/* or just moving to another card, for example with a booster.

*include recode

end

Then a filename for the output file is defined at the top of the edit section, and the new file is written out at the end of the edit section.

----------------------------------------------------------------struct;read=2;ser=c(4,7);crd=c(8,9);max=99

ed

filedef new.dat data

*include correct*include force

Page 12: Quantum Section Wise

*include clean

/* file below recodes data, possibly to a client map/* or just moving to another card, for example with a booster.

*include recode

write new.dat

end

---------------------------------------------------------------

Note that if you are just writing out the same cards in the output file as were in the input file, just

write new.dat

is enough. To specify cards they need to be written out one by one, so:

write new.dat c(101,280)

will not work.

Instead say

write new.dat c(101,180)write new.dat c(201,280)

To create a card eg card 98, that did not previously exist, insert this text in your edits.

(assuming serial number on cols 4-7 and card no on 8-9)

c(9804,9807)=c(104,107)c(9808,9809)=$98$

This is only needed if you want to physically create the card in a data file you are writing out. You can code to this card in your edits in an abstract sense without coding out serial no and card no.

 

 

 

Net Scores

Back to top

In the axes file ...

Page 13: Quantum Section Wise

N10 TotalNET1 ANY FIGUREN01 XN01 YN01 ZNETEND1N01 DK-REFN01 NR;c=-

 

 

Block Filtering Tables

Back to top

In the tabs file ...

flt; c=c412'1/9'ttlBASE:ALL EVER USE PRODUCTtab q1sum gridtab q1 top1tab q2 top1tab q3 top1tab q4 top1 flt;

 

 

Blanking DK's if a Valid Answer also given

Back to top

/* if a valid answer given, blank DK ('9')

In the run file ...

ed

do 1 t1 = 410,413if ( c(t1)'1/8' ) delete c(t1)'9'1 continue

end

 

Page 14: Quantum Section Wise

 

Creating a Table of Contents file

Back to top

At the MS-DOS prompt ...

/* 'contents' is the file that will contain the Table of Contents

>tabcon -o contents

 

Conversion Percentages on a summary grid

Back to top

In the Axes file ...

/* eu : ever use/* ta : total aware/* any ID's can be used

l q1sumn01Q1|Spont!Aware;col(a)=1620n01Q2|Prompt!Aware;col(a)=1621n01Q3|Last!Occasion;col(a)=1622;n01EVER|USE;col(a)=1691;id=eun01TOTAL!AWARE;col(a)=1681;id=tamConv|TotAware| to|EverUse;ex=(eu/ta)*100;sidettlQ1. Skin Care products - AwarenessttlBASE:ALL ADULTS 15+*include q1.qin

 

 

Average no. of brands Mentioned

Back to top

In the edit section of the run file:

ed/*Q13 Average counter

Page 15: Quantum Section Wise

/*this will filter all who didnt say yes in Q12 ie. c778'1'

if(c778n'1') goto 999

t1=0if(c779'1') t1=t1+1if(c779'2') t1=t1+1if(c779'3') t1=t1+1if(c779'4') t1=t1+1if(c779'5') t1=t1+1if(c779'6') t1=t1+1 c793=t1

999 continue

/*Q9c deleting any respondents from no if they said yes anyif(c759'1/4') delete c759'5'end

In the axis file:

l q13ttlQ.13 BRANDS OF CREDIT CARD OWNEDttlBase: ALL WHO OWN A CREDIT CARDn10Totaln01Access;c=c779'1'n01Amex (American Express);c=c779'2'n01Diners;c=c779'3'n01MasterCard;c=c779'4'n01Visa;c=c779'5'n01Other;c=c779'6'n01Not stated;c=-n25;inc=c793n12Average no. of Brands;dec=2

Macro PAGE LAYOUT settings

Back to top

In the Quantum 'run' file, 'a' statement, set page width to 180 (pagwid=180).

In the Macro in Microsoft Word, use the settings below:

Page Setup     Page Size: A4 (11.69" x 8.27")Orientation: LandscapeFont: CourierFont size: Size 7Font weighting: Bold

Page 16: Quantum Section Wise

   Top Margin: 0.3" \ 0.76cmBottom Margin: 0.3" \ 0.76cmLeft Margin: 0.3" \ 0.76cmRight Margin: 0.3" \ 0.76cmGutter Margin: * 0.0" \ 0.00cmHeader: 0.3" \ 0.76cmFooter: 0.3" \ 0.76cm

 

 

Exporting tabs to a CSV file (i.e. Excel)

Back to top

At the MS-DOS screen ...>> qout -p tab1.csv /* creates an intermediary file (tab1.csv)   >> q2cda tab1.csv tab2.csv /* tab2.csv is the final file.

Save tab2.csv as an .XLS file is needed for EXCEL

 

Weighting a CATI jobBack to top

The weighting is done in CATI.

Quantum then uses the run file to reference the columns containing the weighting variable.

Example a ;decp=0 ;op=125 ;spechar=-* ;flush ;pcpos=-1 ;dsp ;wm=1 ;pagwid=180 ;colwid=7

wm1 axdum ;pre=cx(54,57) ;factor ;1/1000

Read this line as:Weighting factor is in colums 54-57. Divide these columns by 1000 to insert the decimal correctly.

Creating an ASCII data fileBack to top

Both methods use the edit section of the run file.

Method 1.

Page 17: Quantum Section Wise

call explode (c860,1,'1/9',c209)

This will take the multipunched column c860 which has codes 1-9 and recode them into ascii format from c209 onwards

IMPORTANT - The output in not the normal 1's and 0's you might expectIf you have codes 1 and 3 on c860 you will get a 1 on c209 and a 3 on c211...

Method 2.if (c610'1') c701'1'if (c610'2') c702'1'

if (c610'8'.and.c621'1') c712'1'

Copy the original run file. Removing the include files for banner, axis, tabs.

Add your edits to the edit section of the new run file The first line above reads: "If 610 is a code 1, write out a 1 to column 701" IMPORTANT - you will need to duplicate the filters in the Axes file (e.g. line 3) If you need to remove the original multipunched column use the clear command

e.g. clear c610clear c(657,699)

Still in the run file add the lines ...filedef 3629.asc data len=800write 3629.asc c(601,780)

Create another run file to run off a holecount on the newly created ascii columns