create missing values in a string variable

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

create missing values in a string variable

progster
dear all,

i'm dealing with a string variable, let's call it var1, having some blank values. spss does not see them as missing values, as other sw like sas do.

i tried something like this:

RECODE var1 (' '='NA').
EXECUTE.


recode var1 ('NA'=MISSING) into var1.
execute.


only the first statement works.

thanks in advance

Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Maguin, Eugene
Time to read the big book, the syntax reference, page  1250 for v21.

Let's say var1 is A2.
Missing values var1('  '). Is a valid satament

RECODE var1 (' '='NA').
Missing values var1('NA'). is also a valid statement.

Gene Maguin

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of progster
Sent: Tuesday, June 17, 2014 9:54 AM
To: [hidden email]
Subject: create missing values in a string variable

dear all,

i'm dealing with a string variable, let's call it var1, having some blank values. spss does not see them as missing values, as other sw like sas do.

i tried something like this:

RECODE var1 (' '='NA').
EXECUTE.


recode var1 ('NA'=MISSING) into var1.
execute.


only the first statement works.

thanks in advance





--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/create-missing-values-in-a-string-variable-tp5726500.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (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

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

David Marso
Administrator
In reply to this post by progster
Maybe look up MISSING VALUES in the manual?

MISSING VALUES var1 (" ").
---


progster wrote
dear all,

i'm dealing with a string variable, let's call it var1, having some blank values. spss does not see them as missing values, as other sw like sas do.

i tried something like this:

RECODE var1 (' '='NA').
EXECUTE.


recode var1 ('NA'=MISSING) into var1.
execute.


only the first statement works.

thanks in advance
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Art Kendall
In reply to this post by progster
try this.
One visually blank line has 5 spaces. the other has just a <carriage return>

data list list/var1 (a5).
begin data
aaaaa
     

bbbbb
n/a
N/A
end data.
missing values var1 ("","n/a","N/A").
frequencies variables = var1.
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Rick Oliver-3
In reply to this post by progster
You can define blanks as user missing:

data list free (",") /var1 (a4).
begin data
a,b,,d,  ,e,   ,f
end data.
missing values var1 ('').
frequencies variables=var1.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        progster <[hidden email]>
To:        [hidden email],
Date:        06/17/2014 08:57 AM
Subject:        create missing values in a string variable
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




dear all,

i'm dealing with a string variable, let's call it var1, having some blank
values. spss does not see them as missing values, as other sw like sas do.

i tried something like this:

RECODE var1 (' '='NA').
EXECUTE.


recode var1 ('NA'=MISSING) into var1.
execute.


only the first statement works.

thanks in advance





--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/create-missing-values-in-a-string-variable-tp5726500.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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


Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Albert-Jan Roskam
In reply to this post by David Marso
Will that also work if there are two or more spaces (assuming that you also want to make those user missing)?.

Or would it be necessary to replace multiple spaces by one space, perhaps by (untested):

do if ( char.length(ltrim(rtrim(var1))) eq 0 ).
+loop.
+  compute var1 = replace("  ", " ").
+end loop.
end if.
missing values var1 (" ").


Regards,

Albert-Jan




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a

fresh water system, and public health, what have the Romans ever done for us?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




----- Original Message -----

> From: David Marso <[hidden email]>
> To: [hidden email]
> Cc:
> Sent: Tuesday, June 17, 2014 4:06 PM
> Subject: Re: [SPSSX-L] create missing values in a string variable
>
> Maybe look up MISSING VALUES in the manual?
>
> MISSING VALUES var1 (" ").
> ---
>
>
>
> progster wrote
>>  dear all,
>>
>>  i'm dealing with a string variable, let's call it var1, having some
> blank
>>  values. spss does not see them as missing values, as other sw like sas do.
>>
>>  i tried something like this:
>>
>>  RECODE var1 (' '='NA').
>>  EXECUTE.
>>
>>
>>  recode var1 ('NA'=MISSING) into var1.
>>  execute.
>>
>>
>>  only the first statement works.
>>
>>  thanks in advance
>
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
> ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
> abyssum?"
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/create-missing-values-in-a-string-variable-tp5726500p5726502.html
>
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (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
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

David Marso
Administrator
No need to TRIM or REPLACE as it were
multiple spaces count as one in this situation.
Try Art's code.

Albert-Jan Roskam wrote
Will that also work if there are two or more spaces (assuming that you also want to make those user missing)?.

Or would it be necessary to replace multiple spaces by one space, perhaps by (untested):

do if ( char.length(ltrim(rtrim(var1))) eq 0 ).
+loop.
+  compute var1 = replace("  ", " ").
+end loop.
end if.
missing values var1 (" ").


Regards,

Albert-Jan




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a

fresh water system, and public health, what have the Romans ever done for us?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




----- Original Message -----
> From: David Marso <[hidden email]>
> To: [hidden email]
> Cc:
> Sent: Tuesday, June 17, 2014 4:06 PM
> Subject: Re: [SPSSX-L] create missing values in a string variable
>
> Maybe look up MISSING VALUES in the manual?
>
> MISSING VALUES var1 (" ").
> ---
>
>
>
> progster wrote
>>  dear all,
>>
>>  i'm dealing with a string variable, let's call it var1, having some
> blank
>>  values. spss does not see them as missing values, as other sw like sas do.
>>
>>  i tried something like this:
>>
>>  RECODE var1 (' '='NA').
>>  EXECUTE.
>>
>>
>>  recode var1 ('NA'=MISSING) into var1.
>>  execute.
>>
>>
>>  only the first statement works.
>>
>>  thanks in advance
>
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
> ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
> abyssum?"
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/create-missing-values-in-a-string-variable-tp5726500p5726502.html
>
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (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
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Rick Oliver-3
Yep. Trailing blanks are ignored when evaluating strings.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        David Marso <[hidden email]>
To:        [hidden email],
Date:        06/17/2014 10:51 AM
Subject:        Re: create missing values in a string variable
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




No need to TRIM or REPLACE as it were
multiple spaces count as one in this situation.
Try Art's code.


Albert-Jan Roskam wrote
> Will that also work if there are two or more spaces (assuming that you
> also want to make those user missing)?.
>
> Or would it be necessary to replace multiple spaces by one space, perhaps
> by (untested):
>
> do if ( char.length(ltrim(rtrim(var1))) eq 0 ).
> +loop.
> +  compute var1 = replace("  ", " ").
> +end loop.
> end if.
> missing values var1 (" ").
>
>
> Regards,
>
> Albert-Jan
>
>
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> All right, but apart from the sanitation, the medicine, education, wine,
> public order, irrigation, roads, a
>
> fresh water system, and public health, what have the Romans ever done for
> us?
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
>
> ----- Original Message -----
>> From: David Marso &lt;

> david.marso@

> &gt;
>> To:

> SPSSX-L@.UGA

>> Cc:
>> Sent: Tuesday, June 17, 2014 4:06 PM
>> Subject: Re: [SPSSX-L] create missing values in a string variable
>>
>> Maybe look up MISSING VALUES in the manual?
>>
>> MISSING VALUES var1 (" ").
>> ---
>>
>>
>>
>> progster wrote
>>>  dear all,
>>>
>>>  i'm dealing with a string variable, let's call it var1, having some
>> blank
>>>  values. spss does not see them as missing values, as other sw like sas
>>> do.
>>>
>>>  i tried something like this:
>>>
>>>  RECODE var1 (' '='NA').
>>>  EXECUTE.
>>>
>>>
>>>  recode var1 ('NA'=MISSING) into var1.
>>>  execute.
>>>
>>>
>>>  only the first statement works.
>>>
>>>  thanks in advance
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> ---
>> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> porcos
>> ne forte conculcent eas pedibus suis."
>> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>> in
>> abyssum?"
>> --
>> View this message in context:
>>
http://spssx-discussion.1045642.n5.nabble.com/create-missing-values-in-a-string-variable-tp5726500p5726502.html
>>
>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

>  (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
>>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/create-missing-values-in-a-string-variable-tp5726500p5726507.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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


Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Art Kendall
In reply to this post by Art Kendall
Copy and paste this syntax into SPSS. Run it.  Look at the missing values counts from frequencies.
data list list/id (f1).
begin data
1
2
3
4
5
6
7
8
9
end data.
string var1(a5).
if id eq 1 var1 = "aaaaa".
if id eq 2 var1 = "n/a".
if id eq 3 var1 = "".
if id eq 4 var1 = " ".
if id eq 5 var1 = "  ".
if id eq 6 var1 = "    ".
if id eq 7 var1 = "     ".
if id eq 8 var1 = "N/A".
if id eq 9 var1 = "AAAAA".
missing values var1 ("","n/a","N/A").
frequencies variables = var1.
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

David Marso
Administrator
In reply to this post by Rick Oliver-3
In creating a simple test example I believe I have discovered a bug.
run this and see if you can tell me why there ends up being a leading space in the first case for b and c.
Is REPLACE up to some funny business?
DATA LIST LIST (",")/ a (a5) b (a5) c (a6).
BEGIN DATA
'x ', 'x  ', 'x   '
'  ', '   ', '    '
END DATA.
COMPUTE a=REPLACE (a,"'","").
COMPUTE b=REPLACE (b,"'","").
COMPUTE c=REPLACE (c,"'","").
COMPUTE ab=A EQ B.
COMPUTE ac=A EQ C.
COMPUTE bc=B EQ C.
LIST.
 
a     b     c            ab       ac       bc
 
x      x     x          .00      .00     1.00
                       1.00     1.00     1.00
 
 
Number of cases read:  2    Number of cases listed:  2
Rick Oliver wrote
Yep. Trailing blanks are ignored when evaluating strings.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]



From:   David Marso <[hidden email]>
To:     [hidden email],
Date:   06/17/2014 10:51 AM
Subject:        Re: create missing values in a string variable
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



No need to TRIM or REPLACE as it were
multiple spaces count as one in this situation.
Try Art's code.


Albert-Jan Roskam wrote
> Will that also work if there are two or more spaces (assuming that you
> also want to make those user missing)?.
>
> Or would it be necessary to replace multiple spaces by one space,
perhaps
> by (untested):
>
> do if ( char.length(ltrim(rtrim(var1))) eq 0 ).
> +loop.
> +  compute var1 = replace("  ", " ").
> +end loop.
> end if.
> missing values var1 (" ").
>
>
> Regards,
>
> Albert-Jan
>
>
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> All right, but apart from the sanitation, the medicine, education, wine,
> public order, irrigation, roads, a
>
> fresh water system, and public health, what have the Romans ever done
for
> us?
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
>
> ----- Original Message -----
>> From: David Marso <

> david.marso@

> >
>> To:

> SPSSX-L@.UGA

>> Cc:
>> Sent: Tuesday, June 17, 2014 4:06 PM
>> Subject: Re: [SPSSX-L] create missing values in a string variable
>>
>> Maybe look up MISSING VALUES in the manual?
>>
>> MISSING VALUES var1 (" ").
>> ---
>>
>>
>>
>> progster wrote
>>>  dear all,
>>>
>>>  i'm dealing with a string variable, let's call it var1, having some
>> blank
>>>  values. spss does not see them as missing values, as other sw like
sas
>>> do.
>>>
>>>  i tried something like this:
>>>
>>>  RECODE var1 (' '='NA').
>>>  EXECUTE.
>>>
>>>
>>>  recode var1 ('NA'=MISSING) into var1.
>>>  execute.
>>>
>>>
>>>  only the first statement works.
>>>
>>>  thanks in advance
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> ---
>> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> porcos
>> ne forte conculcent eas pedibus suis."
>> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>> in
>> abyssum?"
>> --
>> View this message in context:
>>
http://spssx-discussion.1045642.n5.nabble.com/create-missing-values-in-a-string-variable-tp5726500p5726502.html

>>
>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

>  (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
>>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to
email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
abyssum?"
--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/create-missing-values-in-a-string-variable-tp5726500p5726507.html

Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Albert-Jan Roskam
----- Original Message -----

> From: David Marso <[hidden email]>
> To: [hidden email]
> Cc:
> Sent: Tuesday, June 17, 2014 6:40 PM
> Subject: Re: [SPSSX-L] create missing values in a string variable
>
> In creating a simple test example I believe I have discovered a bug.
> run this and see if you can tell me why there ends up being a leading space
> in the first case for b and c.
> Is REPLACE up to some funny business?
> DATA LIST LIST (",")/ a (a5) b (a5) c (a6).
> BEGIN DATA
> 'x ', 'x  ', 'x   '
> '  ', '   ', '    '
> END DATA.
> COMPUTE a=REPLACE (a,"'","").
> COMPUTE b=REPLACE (b,"'","").
> COMPUTE c=REPLACE (c,"'","").
> COMPUTE ab=A EQ B.
> COMPUTE ac=A EQ C.
> COMPUTE bc=B EQ C.
> LIST.
>
> a     b     c            ab       ac       bc
>
> x      x     x          .00      .00     1.00
>                        1.00     1.00     1.00
>
>
> Number of cases read:  2    Number of cases listed:  2

Yes, I see it too on SPSS v20 FP2. Strange.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Bruce Weaver
Administrator
And I see it with v21.0.0.2 (64-bit) running under Windoze 7 Professional, SP1.


Albert-Jan Roskam wrote
----- Original Message -----
> From: David Marso <[hidden email]>
> To: [hidden email]
> Cc:
> Sent: Tuesday, June 17, 2014 6:40 PM
> Subject: Re: [SPSSX-L] create missing values in a string variable
>
> In creating a simple test example I believe I have discovered a bug.
> run this and see if you can tell me why there ends up being a leading space
> in the first case for b and c.
> Is REPLACE up to some funny business?
> DATA LIST LIST (",")/ a (a5) b (a5) c (a6).
> BEGIN DATA
> 'x ', 'x  ', 'x   '
> '  ', '   ', '    '
> END DATA.
> COMPUTE a=REPLACE (a,"'","").
> COMPUTE b=REPLACE (b,"'","").
> COMPUTE c=REPLACE (c,"'","").
> COMPUTE ab=A EQ B.
> COMPUTE ac=A EQ C.
> COMPUTE bc=B EQ C.
> LIST.
>
> a     b     c            ab       ac       bc
>
> x      x     x          .00      .00     1.00
>                        1.00     1.00     1.00
>
>
> Number of cases read:  2    Number of cases listed:  2

Yes, I see it too on SPSS v20 FP2. Strange.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

progster
In reply to this post by Rick Oliver-3
in your simulations everythings works.

also with my data I can actually creating missing values and see them in frequencies table, but later

I would like to select only the not missing:


select if (not missing(var1)).
EXECUTE.

this does not work with my data, it does not the delete the missings rows
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Art Kendall
The syntax below worked for me.

However, most procedures will automatically handle missing data.
the permanent SELECT IF at the end of the syntax below works for me. I cannot recall any version that would not.
data list list/id (f1).
begin data
1
2
3
4
5
6
7
8
9
end data.
string var1(a5).
if id eq 1 var1 = "aaaaa".
if id eq 2 var1 = "n/a".
if id eq 3 var1 = "".
if id eq 4 var1 = " ".
if id eq 5 var1 = "  ".
if id eq 6 var1 = "    ".
if id eq 7 var1 = "     ".
if id eq 8 var1 = "N/A".
if id eq 9 var1 = "AAAAA".
missing values var1 ("","n/a","N/A").
frequencies variables = var1.
temporary.
select if not (missing(var1)).
frequencies variables = var1.
list.
select if not (missing(var1)).
list.
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Richard Ristow
In reply to this post by David Marso
At 12:40 PM 6/17/2014, David Marso wrot
>I believe I have discovered a bug. Run this and see if you can tell
>me why there ends up being a leading space in the first case for b
>and c. Is REPLACE up to some funny business?

It's not about REPLACE, but about DATA LIST. Below is the output of a
test (SPSS 14), but expanding a, b and c to a8 and putting in a LIST
immediately, rather than before the COMPUTE statements. Notice that b
and c have leading blanks before the "'" characters; DATA LIST
started input immediately after the delimiting comma, not waiting for
the "'" characters:

DATA LIST LIST (",")/ a (a8) b (a8) c (a8).
BEGIN DATA
'x ', 'x  ', 'x   '
'  ', '   ', '    '
END DATA.
.  /**/ LIST /*-*/.
List
|-----------------------------|---------------------------|
|Output Created               |18-JUN-2014 14:59:23       |
|-----------------------------|---------------------------|
a        b        c

'x '      'x  '    'x   '
'  '      '   '    '   '

Number of cases read:  2    Number of cases listed:  2

So, of course, those leading blanks are still there after the "'"
characters are replaced by null:

COMPUTE a=REPLACE (a,"'","").
COMPUTE b=REPLACE (b,"'","").
COMPUTE c=REPLACE (c,"'","").
COMPUTE ab=A EQ B.
COMPUTE ac=A EQ C.
COMPUTE bc=B EQ C.
FORMATS ab ac bc (F2).
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |18-JUN-2014 14:59:23       |
|-----------------------------|---------------------------|
a        b        c        ab ac bc

x         x        x       0  0 1

Number of cases read:  2    Number of cases listed:  2
====================================
APPENDIX: Test data and code, as run
====================================
DATA LIST LIST (",")/ a (a8) b (a8) c (a8).
BEGIN DATA
'x ', 'x  ', 'x   '
'  ', '   ', '    '
END DATA.
.  /**/ LIST /*-*/.
COMPUTE a=REPLACE (a,"'","").
COMPUTE b=REPLACE (b,"'","").
COMPUTE c=REPLACE (c,"'","").
COMPUTE ab=A EQ B.
COMPUTE ac=A EQ C.
COMPUTE bc=B EQ C.
FORMATS ab ac bc (F2).
LIST.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: create missing values in a string variable

Jon K Peck
Great catch, Richard.  That's why the first variable works correctly.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Richard Ristow <[hidden email]>
To:        [hidden email],
Date:        06/18/2014 01:07 PM
Subject:        Re: [SPSSX-L] create missing values in a string variable
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




At 12:40 PM 6/17/2014, David Marso wrot
>I believe I have discovered a bug. Run this and see if you can tell
>me why there ends up being a leading space in the first case for b
>and c. Is REPLACE up to some funny business?

It's not about REPLACE, but about DATA LIST. Below is the output of a
test (SPSS 14), but expanding a, b and c to a8 and putting in a LIST
immediately, rather than before the COMPUTE statements. Notice that b
and c have leading blanks before the "'" characters; DATA LIST
started input immediately after the delimiting comma, not waiting for
the "'" characters:

DATA LIST LIST (",")/ a (a8) b (a8) c (a8).
BEGIN DATA
'x ', 'x  ', 'x   '
'  ', '   ', '    '
END DATA.
.  /**/ LIST /*-*/.
List
|-----------------------------|---------------------------|
|Output Created               |18-JUN-2014 14:59:23       |
|-----------------------------|---------------------------|
a        b        c

'x '      'x  '    'x   '
'  '      '   '    '   '

Number of cases read:  2    Number of cases listed:  2

So, of course, those leading blanks are still there after the "'"
characters are replaced by null:

COMPUTE a=REPLACE (a,"'","").
COMPUTE b=REPLACE (b,"'","").
COMPUTE c=REPLACE (c,"'","").
COMPUTE ab=A EQ B.
COMPUTE ac=A EQ C.
COMPUTE bc=B EQ C.
FORMATS ab ac bc (F2).
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |18-JUN-2014 14:59:23       |
|-----------------------------|---------------------------|
a        b        c        ab ac bc

x         x        x       0  0 1

Number of cases read:  2    Number of cases listed:  2
====================================
APPENDIX: Test data and code, as run
====================================
DATA LIST LIST (",")/ a (a8) b (a8) c (a8).
BEGIN DATA
'x ', 'x  ', 'x   '
'  ', '   ', '    '
END DATA.
.  /**/ LIST /*-*/.
COMPUTE a=REPLACE (a,"'","").
COMPUTE b=REPLACE (b,"'","").
COMPUTE c=REPLACE (c,"'","").
COMPUTE ab=A EQ B.
COMPUTE ac=A EQ C.
COMPUTE bc=B EQ C.
FORMATS ab ac bc (F2).
LIST.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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