Good afternoon, Listers,
I have looked in the manual but something is still off with my syntax. I am trying to run DO IF + COMPUTE and I get the following error: Invalid combination of data types in an assignment. Character strings may only be assigned to string variables. Numeric and logical quantities may only be assigned to numeric variables. Use the STRING command to declare new string variables before assigning values to them or consider using the STRING or NUMBER function. Notes: DOBMM1 DOBDD1 DOBYY1 are numeric variables, I have tried using syntax NUMERIC=DOB (f6.0) and running the syntax below and I still get the same error message. Any help would be greatly appreciated. Thank you, Maria Syntax: DO IF DOBMM1 LT 1 OR DOBDD1 LT 1 OR DOBYY1 LT 20. COMPUTE DOB='000000'. END IF. EXECUTE. |
COMPUTE DOB=000000. ???
From: "Maria Suchard [via SPSSX Discussion]" <[hidden email]>
Date: Tue, 30 Jun 2015 15:58:11 -0700 (MST) To: lvccrespo<[hidden email]> Subject: DO IF + COMPUTE COMMAND I have looked in the manual but something is still off with my syntax. I am trying to run DO IF + COMPUTE and I get the following error: Invalid combination of data types in an assignment. Character strings may only be assigned to string variables. Numeric and logical quantities may only be assigned to numeric variables. Use the STRING command to declare new string variables before assigning values to them or consider using the STRING or NUMBER function. Notes: DOBMM1 DOBDD1 DOBYY1 are numeric variables, I have tried using syntax NUMERIC=DOB (f6.0) and running the syntax below and I still get the same error message. Any help would be greatly appreciated. Thank you, Maria Syntax: DO IF DOBMM1 LT 1 OR DOBDD1 LT 1 OR DOBYY1 LT 20. COMPUTE DOB='000000'. END IF. EXECUTE. If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/DO-IF-COMPUTE-COMMAND-tp5730025.html
To start a new topic under SPSSX Discussion, email [hidden email]
To unsubscribe from SPSSX Discussion, click here. NAML |
Yes, thank you. It was that easy.
:-[
On 6/30/2015 4:01 PM, lvccrespo [via
SPSSX Discussion] wrote:
COMPUTE DOB=000000. ??? |
In reply to this post by lvccrespo
* BTW: A string variable has to be defined before it can be changed. STRING DOB (A8). If it is not you get the error. GL, Mario. lvccrespo <[hidden email]> schrieb am 15:19 Mittwoch, 1.Juli 2015: COMPUTE DOB=000000. ??? From: "Maria Suchard [via SPSSX Discussion]" <[hidden email]>
Date: Tue, 30 Jun 2015 15:58:11 -0700 (MST) To: lvccrespo<[hidden email]> Subject: DO IF + COMPUTE COMMAND I have looked in the manual but something is still off with my syntax. I am trying to run DO IF + COMPUTE and I get the following error: Invalid combination of data types in an assignment. Character strings may only be assigned to string variables. Numeric and logical quantities may only be assigned to numeric variables. Use the STRING command to declare new string variables before assigning values to them or consider using the STRING or NUMBER function. Notes: DOBMM1 DOBDD1 DOBYY1 are numeric variables, I have tried using syntax NUMERIC=DOB (f6.0) and running the syntax below and I still get the same error message. Any help would be greatly appreciated. Thank you, Maria Syntax: DO IF DOBMM1 LT 1 OR DOBDD1 LT 1 OR DOBYY1 LT 20. COMPUTE DOB='000000'. END IF. EXECUTE. If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/DO-IF-COMPUTE-COMMAND-tp5730025.html
To start a new topic under SPSSX Discussion, email [hidden email]
To unsubscribe from SPSSX Discussion, click here. NAML View this message in context: Re: DO IF + COMPUTE COMMAND 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
Mario Giesel
Munich, Germany |
Thank you, Mario!
On 7/1/2015 8:33 AM, Mario Giesel [via
SPSSX Discussion] wrote:
|
Administrator
|
In reply to this post by Mario Giesel
AND the reason why the program believes it to be a string is you have the value quoted.
COMPUTE DOB='000000'. IF you want the leading 0's in the representation then use the N format COMPUTE DOB=0. FORMATS DOB (N6). OTOH: The best thing to do would explain what you are trying to do? I presume DOB is Date of Birth. In this case the representation you have selected is useless for date manipulation. Consider using one of the date aggregation functions instead?
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?" |
In reply to this post by Maria Suchard
Maria Other listers are more expert with dates and I'm sure you will get something better from them. It would help all of us if you could list a few cases from your data and post the output to the list. List DOBMM1 DOBDD1 DOBYY1 /cases 20. No idea what you're trying to do, or why, and I'm not much familiar with dates, but from the FM it looks as if you need to create a new string variable first and then use ALTER TYPE if you want it to be a date. Also best to use brackets: SPSS may work without them, but it's easier for the user to interpret and debug if they are used. The following (untested) assumes there is no existing variable called DOB. Try something like: String dob (a6). IF (DOBMM1 LT 1) OR (DOBDD1 LT 1) OR (DOBYY1 LT 20). COMPUTE DOB='000000'. Alter type dob (a6 = date6). List DOBMM1 DOBDD1 DOBYY1 dob /cases 20. John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop -----Original Message----- Good afternoon, Listers, I have looked in the manual but something is still off with my syntax. I am trying to run DO IF + COMPUTE and I get the following error: Invalid combination of data types in an assignment. Character strings may only be assigned to string variables. Numeric and logical quantities may only be assigned to numeric variables. Use the STRING command to declare new string variables before assigning values to them or consider using the STRING or NUMBER function. Notes: DOBMM1 DOBDD1 DOBYY1 are numeric variables, I have tried using syntax NUMERIC=DOB (f6.0) and running the syntax below and I still get the same error message. Any help would be greatly appreciated. Thank you, Maria Syntax: DO IF DOBMM1 LT 1 OR DOBDD1 LT 1 OR DOBYY1 LT 20. COMPUTE DOB='000000'. END IF. EXECUTE. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/DO-IF-COMPUTE-COMMAND-tp5730025.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 |
Administrator
|
John,
The code you posted: < String dob (a6). IF (DOBMM1 LT 1) OR (DOBDD1 LT 1) OR (DOBYY1 LT 20). COMPUTE DOB='000000'. Alter type dob (a6 = date6). List DOBMM1 DOBDD1 DOBYY1 dob /cases 20. > Will not work for so many reasons. Could work if: DO IF (DOBMM1 LT 1) OR (DOBDD1 LT 1) OR (DOBYY1 LT 20). COMPUTE DOB='000000'. END IF. or better IF (DOBMM1 LT 1) OR (DOBDD1 LT 1) OR (DOBYY1 LT 20) DOB='000000'. But if Maria wants a date variable then it makes little sense to create a string variable and ALTER TYPE. OTOH ###### is NOT a valid date format so the ALTER TYPE will fail anyway. Also the smallest value a date variable can contain is 86401. I think maybe we should wait until Maria chimes in with some statement of intent? Please test your code rather than releasing it to the wild in an already feral state.!
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?" |
Thank you all for your help and advice. It is greatly appreciated.
In future I will be sure to include what the code is intended to do. In providing a bit of background- this code is meant to clean participant inputted survey data that is incomplete/erroneous (i.e., DOB=0019). This particular syntax is legacy syntax, I missed the quote around '0000000' the zeros. That was my error for not reading correctly. When I removed the '' the code worked. Again, thank you for your help. I hope you all have a safe and happy 4th. On 7/2/2015 6:23 AM, David Marso [via
SPSSX Discussion] wrote:
John, |
Free forum by Nabble | Edit this page |