{"id":525,"date":"2015-11-02T15:37:22","date_gmt":"2015-01-20T15:37:22","guid":{"rendered":"http:\/\/www.spss-tutorials.com\/?p=465"},"modified":"2021-09-02T07:54:47","modified_gmt":"2021-09-02T05:54:47","slug":"spss-autorecode-command","status":"publish","type":"post","link":"https:\/\/www.spss-tutorials.com\/spss-autorecode-command\/","title":{"rendered":"SPSS AUTORECODE &#8211; Quick Tutorial"},"content":{"rendered":"<!--body-->\n\n<p>This tutorial explains SPSS&rsquo; AUTORECODE<!-- <code>autorecode<\/code> --> command and shows how to use it properly on <a href=\"https:\/\/www.spss-tutorials.com\/downloads\/nominal_strings.sav\">nominal_strings.sav<\/a>, a screenshot of which is shown below. We recommend downloading this data file and following along with the steps in this tutorial.<\/p>\n\n<span class='img w840 smt'>\n    <img src='https:\/\/spss-tutorials.com\/img\/spss-autorecode-data-view.png' alt='SPSS AUTORECODE - Data View'>\n<\/span>\n\n<h2>SPSS AUTORECODE - What Is It?<\/h2>\n\n<p>SPSS AUTORECODE creates a new <a href=\"https:\/\/www.spss-tutorials.com\/spss-numeric-variables-basics\/\">numeric variable<\/a> from a <a href=\"https:\/\/www.spss-tutorials.com\/spss-string-variables-basics\/\">string variable<\/a>. The string values are recoded into integer numbers (1, 2, 3 and so on). Each number then receives the string value it represents as a value label.<br>\nRegarding our data file, note in <a href=\"https:\/\/www.spss-tutorials.com\/spss-data-editor-window\/#spss-variable-view\">variable view<\/a> that <span class='var'>emot_1<\/span> through <span class='var'>emot_5<\/span> are string variables. We'll now AUTORECODE the first one and inspect the result with the <a href=\"https:\/\/www.spss-tutorials.com\/spss-syntax\/ \">syntax<\/a> below.<\/p>\n\n<h2>SPSS AUTORECODE - Syntax Example 1<\/h2>\n\n<div class='code'><strong>*1. Create numeric variable emo_1 from string emot_1.<br><\/strong><br>autorecode emot_1 \/into emo_1.<br><br><strong>*2. Show values and value labels in following output tables.<br><\/strong><br>set tnumbers both.<br><br><strong>*3. Inspect result.<br><\/strong><br>frequencies emo_1.<\/div><!--class='code'-->\n<h2>Result<\/h2>\n\n<span class='img w840 smt'><img src='https:\/\/spss-tutorials.com\/img\/spss-autorecode-frequency-table.png' alt='SPSS AUTORECODE - Frequency Table'><\/span>\n\n<p>Note in this table that the string values are first sorted alphabetically before they're assigned to numbers 1 and 2.<\/p>\n\n<h2>SPSS AUTORECODE - PRINT Subcommand<\/h2>\n\n<p>Whenever you use AUTORECODE, it's nice to see which string values are converted to which numeric values. We can have SPSS print this coding scheme in the <a href=\"https:\/\/www.spss-tutorials.com\/spss-output\/\">output viewer window<\/a> by simply adding a PRINT subcommand as shown below.<\/p>\n\n<h2>SPSS AUTORECODE - Syntax Example 2<\/h2>\n\n<div class='code'><strong>*Print coding scheme in output viewer window.<br><\/strong><br>autorecode emot_2<br>\/into emo_2<br>\/print.<\/div><!--class='code'-->\n<h2>Result<\/h2>\n\n<span class='img w840 smt'><img src='https:\/\/spss-tutorials.com\/img\/spss-autorecode-coding-scheme-in-output.png' alt='SPSS AUTORECODE - Coding Scheme'><\/span>\n\n<p>Note that there's something awkward here: it seems as if 2 new values are converted into 3 new values. What's going on is that the new value 1 indicates an empty (zero character) string value. In SPSS logic, that's just another distinct (and valid) string value.<br>\nWe can see in <a href=\"https:\/\/www.spss-tutorials.com\/spss-data-editor-window\/#spss-data-view\">data view<\/a> that the second case indeed has an empty string value on <span class='var'>emot_2<\/span>.<\/p>\n\n<h2>SPSS AUTORECODE - BLANKS Subcommand<\/h2>\n\n<p>We just saw that AUTORECODE treats empty string values the same as non empty string values. However, we usually see empty string values as <a href=\"https:\/\/www.spss-tutorials.com\/spss-missing-values\/ \">missing values<\/a> and we like to have them recoded last. We can do so by adding a BLANKS subcommand as shown in the syntax below, step 2. Before doing so, we first delete all new variables.<\/p>\n\n<h2>SPSS AUTORECODE - Syntax Example 3<\/h2>\n\n<div class='code'><strong>*1. Delete all new variables.<br><\/strong><br>add files file *\/keep id to emot_5.<br><br><strong>*2. Blank strings should become missing values in new variable(s).<br><\/strong><br>autorecode emot_2<br>\/into emo_2<br>\/blank missing <br>\/print.<\/div><!--class='code'-->\n<h2>Result<\/h2>\n\n<span class='img w840 smt'><img src='https:\/\/spss-tutorials.com\/img\/spss-autorecode-coding-scheme-missings-in-output.png' alt='SPSS AUTORECODE - Coding Scheme with missings in output'><\/span>\n\n<h2>SPSS AUTORECODE - GROUP Subcommand<\/h2>\n\n<p>At this point, note that each AUTORECODE example we ran resulted in a different coding scheme. When we take a close look at our data, however, we see that our string variables mostly contain similar values. This suggests that the same answer categories were used for these 5 questions.<br>\nIn this common scenario, we usually want to have our new variables consistently coded. That is, we want to have identical value labels over such a set of variables. This is accomplished by adding a GROUP subcommand as shown below.<\/p>\n\n<h2 id='ex4'>SPSS AUTORECODE - Syntax Example 4<\/h2>\n\n<div class='code'><strong>*1. Delete all new variables.<br><\/strong><br>add files file *\/keep id to emot_5.<br><br><strong>*2. Use same coding scheme for all variables<br><\/strong><br>autorecode emot_1 to emot_5<br>\/into emo_1 to emo_5<br>\/group<br>\/blank missing<br>\/print.<\/div><!--class='code'-->\n<h2>Result<\/h2>\n\n<span class='img w840 smt'><img src='https:\/\/spss-tutorials.com\/img\/spss-autorecode-coding-scheme-missings-in-output-2.png' alt='SPSS AUTORECODE - Coding Scheme with missings in output'><\/span>\n\n<p>Note that we basically converted the entire data file in one go with our last command. However, there's one thing we don't like: value 2 is used for &ldquo;Don't know \/ no answer&rdquo;. There nothing really wrong with that but it's a bit awkward that this value is among the values used for emotional expressions.<br>\nAUTORECODE doesn't have any option for circumventing this but we'll now offer two ways for correcting it.<\/p>\n\n<h2>Option 1: Basic Syntax<\/h2>\n\n<p>One option here is to <a href=\"https:\/\/www.spss-tutorials.com\/spss-recode-command\/ \">RECODE<\/a> 2 into 7 and then adjust the value labels manually. Fortunately, we can do so for all relevant variables simultaneously as shown below.<\/p>\n\n<div class='code'><strong>*1. Recode 2 into 7 for all new variables.<br><\/strong><br>recode emo_1 to emo_5 (2 = 7).<br>execute.<br><br><strong>*2. Remove value label from 2 and apply value labels to 6 and 7.<br><\/strong><br>add value labels emo_1 to emo_5 <br>2 &#39;&#39;<br>6 &#39;(Blank)&#39;<br>7 &#39;Don&#39;&#39;t know \/ no answer&#39;.<\/div><!--class='code'-->\n<h2>Option 2: Recode with Value Labels Tool<\/h2>\n\n<p>A much more elegant option for dealing with the &ldquo;Don't know&rdquo; values is using our <a href=\"https:\/\/www.spss-tutorials.com\/spss-recode-with-value-labels-tool\/\">SPSS - Recode with Value Labels Tool<\/a>. After installing it, it can swap values 2 and 5 together with their value labels by running the syntax below.<\/p>\n\n<div class='code'><strong>*Note: syntax below only runs after installing SPSS Recode With Value Labels Tool.<br><\/strong><br>SPSSTUTORIALS RECODEWITHVALUELABELS <br>VARIABLES = &#39;emo_1 to emo_5&#39; <br>OLDVALUES = &#39;2 5&#39; <br>NEWVALUES = &#39;5 2&#39;.<\/div><!--class='code'-->\n","protected":false},"excerpt":{"rendered":"<p>SPSS AUTORECODE converts a categorical string variable into a numeric variable with value labels.<\/p>\n<p>This tutorial quickly walks you through with some examples.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[245],"tags":[],"class_list":["post-525","post","type-post","status-publish","format-standard","hentry","category-aa"],"_links":{"self":[{"href":"https:\/\/www.spss-tutorials.com\/wp-json\/wp\/v2\/posts\/525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.spss-tutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spss-tutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spss-tutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spss-tutorials.com\/wp-json\/wp\/v2\/comments?post=525"}],"version-history":[{"count":0,"href":"https:\/\/www.spss-tutorials.com\/wp-json\/wp\/v2\/posts\/525\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.spss-tutorials.com\/wp-json\/wp\/v2\/media?parent=525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spss-tutorials.com\/wp-json\/wp\/v2\/categories?post=525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spss-tutorials.com\/wp-json\/wp\/v2\/tags?post=525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}