Hello!!! spss experts I'm reviewing some date variables in the database with 100,000 records, I'm calculating the no. of nights subtracting the date in which indicated that entry to Guatemala versus the date on which the interview is done, since contact is made to visitors who go out in the different borders, eg. Join Guatemala on May 15, 2013 and the interview is conducted on Mar 22, 2014 the result is 311 nights, this result was compared with the total number of days minus 1 indicating that you were in Guatemala in this case the record indicates 22 days, what I would like to do is replace the date of entry taking into account the total number of days mentioned. example. facha_entrada = 05/15/2013 fecha_entrevista = 03/22/2014 Total_dias = 22 fecha_entrada_real = 02/28/2014 What I am doing is: COMPUTE Estadia_promedio = RND ((fecha_entrevista - fecha_entrada) / time.days (1)). COMPUTE resul_resta = Estadia_promedio-Total_dias. this is where I stay, I have not found the way in SPSS to replace the correct data that would be fecha_ingreso = 02/28/2014 for me to 22 days. it's a bit complicated because sometimes I have to subtract and in others I add In excel I indicate to the formula that if it is 0 copy the date as it is written, if it is a negative value I make a subtraction and if it is a positive value I make a sum. THIS IN EXCEL I EXECUTE WITH: =SI(SIGNO(AR2)="0",AM2,SI(SIGNO(AR2)="-1",AM2-AR2,AM2+AR2)) But my desire is to do it in spss. you could help me, with this. Thank you very much for your comments. Sincerely, Javier Figueroa Procesamiento y Análisis de bases de datos Cel: 5927-4748 / 4970-1940 Casa: 2289-0184 |
I don’ t know whether others already have responded but I’m confused by what you are asking for and the example you give. In the example, it seems like the person
entered Guatemala on May 15, 2013, but didn’t actually do so because the true entry date was February 28, 2014, and was interviewed on March 22, 2014. (I don’t know if you have considered using the date.diff function but this function computes intervals between
two dates and returns the difference in a choice of several different time units.) You say: “…
what I would like to do is replace the date of entry taking into account the total number of days mentioned.”
Does that mean that in this example you want to replace May 15, 2013 (the alleged entry date) with February 28, 2014 (true known entry date) and then make the
computation? But, isn’t the computation just If (entrada_real gt entrada) entrada=entrada_real. Gene Maguin From: SPSSX(r) Discussion <[hidden email]>
On Behalf Of Javier Figueroa Hello!!! spss experts I'm reviewing some date variables in the database with 100,000 records, I'm calculating the no. of nights subtracting the date in which indicated that entry to Guatemala versus the date on which the interview is done, since contact is made
to visitors who go out in the different borders, eg. Join Guatemala on May 15, 2013 and the interview is conducted on Mar 22, 2014 the result is 311 nights, this result was compared with the total number of days minus 1 indicating that you were in Guatemala
in this case the record indicates 22 days, what I would like to do is replace the date of entry taking into account the total number of days mentioned. example. facha_entrada = 05/15/2013 fecha_entrevista = 03/22/2014 Total_dias = 22 fecha_entrada_real = 02/28/2014 What I am doing is: COMPUTE Estadia_promedio = RND ((fecha_entrevista - fecha_entrada) / time.days (1)). COMPUTE resul_resta = Estadia_promedio-Total_dias. this is where I stay, I have not found the way in SPSS to replace the correct data that would be fecha_ingreso = 02/28/2014 for me to 22 days. it's a bit complicated because sometimes I have to subtract and in others I add In excel I indicate to the formula that if it is 0 copy the date as it is written, if it is a negative value I make a subtraction and if it is a positive value I make a sum. THIS IN EXCEL I EXECUTE WITH: =SI(SIGNO(AR2)="0",AM2,SI(SIGNO(AR2)="-1",AM2-AR2,AM2+AR2)) But my desire is to do it in spss. you could help me, with this. Thank you very much for your comments. Sincerely, -- Javier Figueroa Cel: 5927-4748 / 4970-1940 Casa: 2289-0184 ===================== 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
|
Of course you first want to create a new variable and work with that as a
corrected version. UNTESTED for exact syntax. compute MyVarCorrected = Myvar. apply dictionary ... and then correct the contents of MyVarCorrected. ----- Art Kendall Social Research Consultants -- Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants |
Hello!!!! First I would like to thank you for the time you spent reading my tangled request for help, I apologize for my English, I understand that it must be complicated to try to understand someone who does not speak, let alone write another language. (MY ENGLISH IS FATAL, I KNOW). but although they do not believe it, they have helped me a lot, not only on this occasion but also on many previous occasions. The command that Maguin suggested to me, Eugene is excellent and I found a page. which indicates how to deal with the formats of dates, very good. thanks again and this is how I was able to solve my problem, again thanks. I also thank Art Kendall, for his time and contributions. in general to everyone in the forum, THANK YOU. /* creación de datos ficticios. /* creación de datos ficticios. data list list /p11 (date11) fecha (date11) DIAS_1 DIAS_2 DIAS_3 DIAS_4 DIAS_5. begin data. 10-Feb-2014 01-Nov-2013 1.0 1.0 2.0 . . 19-Feb-2014 15-Nov-2013 1.0 3.0 4.0 . . 17-Feb-2014 25-Aug-2013 30.0 6.0 15.0 . 02-Jun-2015 06-May-2016 1.0 1.0 1.0 1.0 1.0 02-Jun-2015 06-May-2016 1.0 1.0 1.0 1.0 1.0 02-Jun-2018 04-Jun-2016 1.0 1.0 1.0 . . 10-May-2018 15-May-2016 3.0 1.0 1.0 1.0 . 28-Feb-2014 22-Mar-2014 3.0 1.0 3.0 3.0 12.0 end data. execute. numeric id(f8.0). compute id=$casenum. execute. variable level dias_1 dias_2 dias_3 dias_4 dias_5 (scale). /* calculando estadía promedio (resta de fecha de ingreso a Guatemala - Fecha que se realiza la entrevista), se entrevista a personas que salen de pais. COMPUTE Estadia_promedio = RND ((fecha - p11) / time.days (1)). EXECUTE. /* suma de total de días que visitan sitios o lugares de Guatemala (sirve de referencia). /* resul_resta variable que se utiliza para comparar el tiempo que indica que se estuvo en lugares turísticos con la resta de la fecha de entrada con la que se realizo la entrevista. COMPUTE Suma_Dias=SUM(DIAS_1,Dias_2,Dias_3,DIAS_4,DIAS_5). COMPUTE resul_resta = RND(Estadia_promedio-Suma_Dias). EXECUTE. /* Variables de comparación. COMPUTE fecha_revisada_1=0. FORMATS fecha_revisada_1 (date11). EXECUTE. /* Normalizando fecha de ingreso a GUATEMALA. if resul_resta=0 fecha_revisada_1=p11. if resul_resta<>0 fecha_revisada_1=datesum(p11,resul_resta,'days'). EXECUTE. /* comparación con la variable normalizada. COMPUTE Estadia_promedio2 = RND ((fecha - fecha_revisada_1) / time.days (1)). EXECUTE. .thank you, I know there are thousands of ways to work with the formats of dates and if you can extend this would be very helpful. El mié., 27 feb. 2019 a las 9:26, Art Kendall (<[hidden email]>) escribió: Of course you first want to create a new variable and work with that as a Javier Figueroa Procesamiento y Análisis de bases de datos Cel: 5927-4748 / 4970-1940 Casa: 2289-0184 |
In reply to this post by Javier Figueroa
Eliminate those unnecessary EXECUTE statements.
===================== 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 |
Ok, thanks. El mié., 27 feb. 2019 a las 19:50, David Marso (<[hidden email]>) escribió: Eliminate those unnecessary EXECUTE statements. Javier Figueroa Procesamiento y Análisis de bases de datos Cel: 5927-4748 / 4970-1940 Casa: 2289-0184 |
Free forum by Nabble | Edit this page |