LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2011)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 29 Nov 2011 07:45:11 -0500
Reply-To:   Art@DrKendall.org
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Art Kendall <Art@DrKendall.org>
Organization:   Social Research Consultants
Subject:   Re: How to calculate missing values in a string with multiple responses and semi-colons
Comments:   To: huang jialin <huangpsych@gmail.com>
In-Reply-To:   <CACdH1VhNL9_AAE0+FPcLoLVXMQj52Tdcv2dbYehsddM6Bh3Uww@mail.gmail.com>
Content-type:   text/html; charset=UTF-8

<html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> </head> <body text="#000000" bgcolor="#FFFFFF"> <font size="+1">side note: if you review the whole conversation, you can see the value of the list. As time went on, the group worked out an understanding of what your question is.<br> <br> Why the earlier post? Rick Oliver built on my suggestion that the string be written out to a disk file. He pointed out that DATA LIST LIST could specify a separator when reading a text file. Something I had forgotten. I pointed out that in fact there could be 2 different separator characters, and asked if the list knew of a way to specify a tab character as the separator character.<br> <br> What I now think you question is:<br> There is a string of semicolon separated fields. The fields can contain 0 to 3 digits. Each field contains 3 variables in a multiple response set.<br> </font>You actually have 50 sets of 3 variables.<br> <font size="+1">You want to have 3 kinds of user missing values.<br>    1 kind e.g., -999 to indicate missing at the end, i.e., trailing<br>    another kind e.g., -998 to indicate a variable that is null but is within the set of variables with responses not trailing<br>   a third kind e.g., -997 to indicate a variable set that has some content but but fewer than 3 responses in a set</font><br> <br> Maybe your syntax would include something like<br> Missing values v1 to v150 (-999 thru -1).<br> value labels v1 to v150<br>    1 'something'<br>    2 'something else'<br>    3 'another label'<br>  -999 'did not get to question'<br>  -998 'read but not answered'<br>  -997 'partially answered question'.<br> <br> Is this understanding correct?<br> <br> Do you now have a working set of syntax?<br> <br> Art Kendall<br> Social Research Consultants<br> On 11/28/2011 4:00 PM, huang jialin wrote: <blockquote cite="mid:CACdH1VhNL9_AAE0+FPcLoLVXMQj52Tdcv2dbYehsddM6Bh3Uww@mail.gmail.com" type="cite">Hi Art, <div><br> </div> <div>Thanks for the reply. Would you explain how it relates to my question? </div> <div><br> </div> <div>BTW, there are goofy characters in the email. Is it because my email?</div> <div><br> </div> <div>Thanks.</div> <div><br> </div> <div>Jialin<br> <br> <div class="gmail_quote">On Mon, Nov 28, 2011 at 1:49 PM, Art Kendall <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:Art@drkendall.org">Art@drkendall.org</a>&gt;</span> wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> <div text="#000000" bgcolor="#FFFFFF"> <font size="+1">Nice one. I forgot that one can specify the delimiter.</font> I can see how to use semicolon, comma, pipe or most likely any printing character,<br> is there a way to specify a tab (ctrl-h in ASCII)?<br> <br> <br> Lo and behold!!<br> this works even with 2 specified separators this syntax if for tilda and x  but x and X works too.<br> <br> new file.<br> set blanks 0.<br> data list list ("~","x") file='c:\project\tilda x separated.txt' /numvar1 to numvar3.<br> compute numvalid=nvalid(numvar1 to numvar3).<br> compute ID = $casenum.<br> list /variables = ID numvar1 to numvar3.<br> -----<br> the data<br> -----<br> 123x456x789<br> xxx<br> 123x456x789<br> 123xx<br> 123~456~789<br> ~~~<br> 123~456x789<br> 123~x <div class="im"><br> <br> Art Kendall<br> Social Research Consultants<br> <br> <br> </div> <div class="im"> On 11/28/2011 1:53 PM, Rick Oliver wrote: </div> <blockquote type="cite"> <div class="im"><font size="2" face="sans-serif">Rick Oliver<br> Senior Information Developer<br> IBM Business Analytics (SPSS)<br> E-mail: <a moz-do-not-send="true" href="mailto:oliverr@us.ibm.com" target="_blank">oliverr@us.ibm.com</a></font> <br> <br> <font size="2" face="sans-serif">****sample data***.</font> <br> <font size="2" face="sans-serif">data list list /stringvar (a120).</font> <br> <font size="2" face="sans-serif">begin data</font> <br> <font size="2" face="sans-serif">1;1;5;1;4;3;;;2;2;134;5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> <br> <font size="2" face="sans-serif">;5;3;;1;3;145;2;3;;5;5;;5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> <br> <font size="2" face="sans-serif">;;1;3;1;5;1;4;4;2;1;;2;3;;4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> <br> <font size="2" face="sans-serif">1;1;;3;;1;4;;4;2;3;5;;3;;4;5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> <br> <font size="2" face="sans-serif">3;5;1;3;1;;1;2;3;;2;2;;3;;;3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> <br> <font size="2" face="sans-serif">3;4;3;1;3;3;145;1;3;5;4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> <br> <font size="2" face="sans-serif">1;1;4;1;4;2;1;5;;3;234;2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> <br> <font size="2" face="sans-serif">1;1;5;1;4;2;1;1;2;2;234;4;5;4;1;145;2;2;3;125;3;5;1;2;2;5;234;3;2;3;2;2;5;3;4;;135;;4;4;135;;1;2;;234;;;;2</font> <br> <font size="2" face="sans-serif">2;4;3;1;3;3;145;2;3;4;2;1;1;3;235;1;3;5;235;3;3;4;125;5;1;2;3;1;2;4;3;5;4;135;3;4;3;2;2;5;1;5;245;2;1;3;124;4;2;</font> <br> <font size="2" face="sans-serif">end data.</font> <br> <font size="2" face="sans-serif">write outfile='c:\temp\temp.txt' /stringvar.</font> <br> <font size="2" face="sans-serif">execute.</font> <br> <font size="2" face="sans-serif">***real code starts here. just read the original text data file this way***.</font> <br> </div> <font size="2" face="sans-serif">data list list (";")  file='c:\temp\temp.txt' /numvar1 to numvar50.</font> <br> <div class="im"> <font size="2" face="sans-serif">compute numvalid=nvalid(numvar1 to numvar50).</font> <br> <font size="2" face="sans-serif">execute.</font> <br> <br> <br> <br> </div> <font size="1" color="#5f5f5f" face="sans-serif">From:     </font><font size="1" face="sans-serif">huang jialin <a moz-do-not-send="true" href="mailto:huangpsych@gmail.com" target="_blank">&lt;huangpsych@gmail.com&gt;</a></font> <br> <font size="1" color="#5f5f5f" face="sans-serif">To:     </font><font size="1" face="sans-serif"><a moz-do-not-send="true" href="mailto:SPSSX-L@listserv.uga.edu" target="_blank">SPSSX-L@listserv.uga.edu</a></font> <br> <font size="1" color="#5f5f5f" face="sans-serif">Date:     </font><font size="1" face="sans-serif">11/28/2011 12:19 PM</font> <br> <font size="1" color="#5f5f5f" face="sans-serif">Subject:     </font><font size="1" face="sans-serif">Re: How to calculate missing values in a string with multiple        responses and semi-colons</font> <br> <font size="1" color="#5f5f5f" face="sans-serif">Sent by:     </font><font size="1" face="sans-serif">"SPSSX(r)

Discussion" <a moz-do-not-send="true" href="mailto:SPSSX-L@listserv.uga.edu" target="_blank">&lt;SPSSX-L@listserv.uga.edu&gt;</a></font> <br> <div class="im"> <hr noshade="noshade"> <br> <br> <br> <font size="3">Hi Gene,</font> <br> <br> <font size="3">Thanks for your quick response. I will rephrase my question. That is, I only want to count the missing values before the last integer. Am I making sense now?</font> <br> <br> <font size="3">Sorry for the confusion.</font> <br> <br> <font size="3">Sincerely,</font> <br> </div> <font size="3">Jialin <br> </font> <div class="im"> <br> <font size="3">On Mon, Nov 28, 2011 at 12:08 PM, Gene Maguin &lt;</font><a moz-do-not-send="true" href="mailto:emaguin@buffalo.edu" target="_blank"><font size="3" color="blue"><u>emaguin@buffalo.edu</u></font></a><font size="3">&gt; wrote:</font> <br> <font size="2" color="#004080" face="Calibri">Ok, I missed accounting for the situation where the first item is missing. This will do that.</font> <p><font size="2" color="#004080" face="Calibri"> </font> </p> <p><font size="2" color="#004080" face="Calibri">Compute

nmissing=0.</font> </p> </div> <p><font size="2" color="#004080" face="Calibri">If (substr(V,1,1) eq ‘;’) nmissing=nmissing+1. </font> </p> <div class="im"> <p><font size="2" color="#004080" face="Calibri">Loop #i=1 to 149.</font> </p> <p><font size="2" color="#004080" face="Calibri">Do If (substr(V,#i,2) eq ‘;;’).</font> </p> </div> <p><font size="2" color="#004080" face="Calibri">+ compute nmissing=nmissing+1.</font> </p> <p><font size="2" color="#004080" face="Calibri">Else if (substr(V,#i,2) eq ‘ ‘).</font> </p> <p><font size="2" color="#004080" face="Calibri">+ break.</font> </p> <div class="im"> <p><font size="2" color="#004080" face="Calibri">End if.</font> </p> <p><font size="2" color="#004080" face="Calibri">End loop.</font> </p> <p><font size="2" color="#004080" face="Calibri"> </font> </p> <p><font size="2" color="#004080" face="Calibri">I don’t know what you mean by this: ‘</font><font size="3">Second, I do not want to count the missing values when there is no response at all’. How do you tell the difference between a missing value and ‘no response at all’. </font> </p> </div> <p><font size="2" color="#004080" face="Calibri"> </font> </p> <p><font size="2" color="#004080" face="Calibri"> </font> </p> <div class="im"> <p><font size="2" color="#004080" face="Calibri"> </font> </p> <p><font size="2" face="Tahoma"><b>From:</b> huang jialin [mailto:</font><a moz-do-not-send="true" href="mailto:huangpsych@gmail.com" target="_blank"><font size="2" color="blue" face="Tahoma"><u>huangpsych@gmail.com</u></font></a><font size="2" face="Tahoma">] <b><br> Sent:</b> Monday, November 28, 2011 12:54 PM<b><br> To:</b> Gene Maguin<b><br> Cc:</b> </font><a moz-do-not-send="true" href="mailto:SPSSX-L@listserv.uga.edu" target="_blank"><font size="2" color="blue" face="Tahoma"><u>SPSSX-L@listserv.uga.edu</u></font></a><font size="2" face="Tahoma"><b><br> Subject:</b> Re: How to calculate missing values in a string with multiple responses and semi-colons</font> </p> </div> <p><font size="3"> </font> </p> <p><font size="3">Hi Gene,</font> </p> <div class="im"> <p><font size="3"> </font> </p> <p><font size="3">Thanks for your email. There are still two questions needed to be solved. First, if the first item is missing, there is only one semicolon in the beginning of the string. Thus, it may not fit the comparison of pair of semicolons. Second, I do not want to count the missing values when there is no response at all. How can I do it?</font> </p> </div> <p><font size="3"> </font> </p> <p><font size="3">Thank you very much.</font> </p> <p><font size="3"> </font> </p> <p><font size="3">Sincerely,</font> </p> <p><font size="3">Jialin</font> </p> <p><font size="3"> </font> </p> <div class="im"> <p><font size="3"> </font> </p> <p><font size="3">On Mon, Nov 28, 2011 at 11:42 AM, Gene Maguin &lt;</font><a moz-do-not-send="true" href="mailto:emaguin@buffalo.edu" target="_blank"><font size="3" color="blue"><u>emaguin@buffalo.edu</u></font></a><font size="3">&gt; wrote:</font> </p> <p><font size="2" color="#004080" face="Calibri">It looks like adjacent semicolons (;;) mean a missing data value. I think all you need to do is to count pairs of semicolons. Let’s say the that the variable, V, is A150.</font> </p> <p><font size="2" color="#004080" face="Calibri"> </font> </p> <p><font size="2" color="#004080" face="Calibri">Compute

nmissing=0.</font> </p> <p><font size="2" color="#004080" face="Calibri">Loop #i=1 to 149.</font> </p> <p><font size="2" color="#004080" face="Calibri">Do If (substr(V,#i,2) eq ‘;;’).</font> </p> </div> <p><font size="2" color="#004080" face="Calibri">+ compute nmissing=nmissing+1.</font> </p> <p><font size="2" color="#004080" face="Calibri">Else if (substr(V,#i,2) eq ‘ ‘).</font> </p> <p><font size="2" color="#004080" face="Calibri">+ break.</font> </p> <p><font size="2" color="#004080" face="Calibri">End if.</font> </p> <p><font size="2" color="#004080" face="Calibri">End loop.</font> </p> <p><font size="2" color="#004080" face="Calibri"> </font> </p> <div class="im"> <p><font size="2" color="#004080" face="Calibri">&gt;&gt;If you copy this text, make sure the quotes are straight and not curly. I think spss does not like curly.</font> </p> </div> <p><font size="2" color="#004080" face="Calibri"> </font> </p> <p><font size="2" color="#004080" face="Calibri"> </font> </p> <div class="im"> <p><font size="2" color="#004080" face="Calibri"> </font> </p> <p><font size="2" face="Tahoma"><b>From:</b> SPSSX(r) Discussion [mailto:</font><a moz-do-not-send="true" href="mailto:SPSSX-L@LISTSERV.UGA.EDU" target="_blank"><font size="2" color="blue" face="Tahoma"><u>SPSSX-L@LISTSERV.UGA.EDU</u></font></a><font size="2" face="Tahoma">] <b>On Behalf Of </b>huang jialin<b><br> Sent:</b> Monday, November 28, 2011 12:23 PM<b><br> To:</b> </font><a moz-do-not-send="true" href="mailto:SPSSX-L@LISTSERV.UGA.EDU" target="_blank"><font size="2" color="blue" face="Tahoma"><u>SPSSX-L@LISTSERV.UGA.EDU</u></font></a><font size="2" face="Tahoma"><b><br> Subject:</b> How to calculate missing values in a string with multiple responses and semi-colons</font> </p> </div> <p><font size="3"> </font> </p> <p><font size="3">Hello,</font> </p> <p><font size="3"> </font> </p> <p><font size="3">I have a variable in a dataset formatted as following:</font> </p> <div class="im"> <p><font size="3">1;1;5;1;4;3;;;2;2;134;5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> </p> <p><font size="3">;5;3;;1;3;145;2;3;;5;5;;5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> </p> <p><font size="3">;;1;3;1;5;1;4;4;2;1;;2;3;;4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> </p> <p><font size="3">1;1;;3;;1;4;;4;2;3;5;;3;;4;5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> </p> <p><font size="3">3;5;1;3;1;;1;2;3;;2;2;;3;;;3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> </p> <p><font size="3">3;4;3;1;3;3;145;1;3;5;4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> </p> <p><font size="3">1;1;4;1;4;2;1;5;;3;234;2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</font> </p> <p><font size="3">1;1;5;1;4;2;1;1;2;2;234;4;5;4;1;145;2;2;3;125;3;5;1;2;2;5;234;3;2;3;2;2;5;3;4;;135;;4;4;135;;1;2;;234;;;;2</font> </p> <p><font size="3">2;4;3;1;3;3;145;2;3;4;2;1;1;3;235;1;3;5;235;3;3;4;125;5;1;2;3;1;2;4;3;5;4;135;3;4;3;2;2;5;1;5;245;2;1;3;124;4;2;</font> </p> <p><font size="3"> </font> </p> </div> <p><font size="3">There is 50 items in total, and they are separated by 49 semi-colons. For certain items, they contains multiple responses. I want to calculate how many items was missed before the responses stopped.</font> </p> <div class="im"> <p><font size="3"> </font> </p> <p><font size="3">I tried to use length(trim(var)) to calculate the length of string, but it only turned out to be the number of responses. It is the same as using CHAR.LENGTH(var).</font> </p> <p><font size="3"> </font> </p> </div> <p><font size="3">How can I got the number of missing items? </font> </p> <p><font size="3"> </font> </p> <p><font size="3">I would appreciate your helps. </font> </p> <p><font size="3"> </font> </p> <p><font size="3">Sincerely,</font> </p> <p><font size="3">Jialin</font> </p> <p><font size="3"> </font> </p> <p><font size="3"> </font> </p> <p> </p> <p> </p> </blockquote> </div> ===================== To manage your subscription to SPSSX-L, send a message to <a moz-do-not-send="true" href="mailto:LISTSERV@LISTSERV.UGA.EDU" target="_blank">LISTSERV@LISTSERV.UGA.EDU</a> (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD </blockquote> </div> <br> </div> </blockquote> </body> </html>

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


Back to: Top of message | Previous page | Main SPSSX-L page