Hello listers,
Topic: UPDATE. The macro below (!UPD) does not produce the correct IN-variable. All cases of the updated master sample show values of "1". Why? Michael data list list / id (f2) v2 (F2) v3 (Edate11). begin data. 1 22 12/10/11 2 20 20/9/10 3 18 18/6/10 4 17 30/7/11 5 44 17/4/10 6 16 1/1/11 7 18 30/12/11 8 22 14/10/10 9 32 20/9/11 10 33 17/2/10 end data. list. sav out = 'C:\temp\master_02012012.sav'. data list list / id (f2) v2 (F2) v3 (Edate11). begin data. 1 22 10/10/11 6 16 21/1/11 8 22 16/10/10 10 23 17/2/11 end data. list. sav out = 'C:\temp\correction_02022012.sav'. get file = 'C:\temp\correction_02022012.sav'. SORT CASE BY id. DATASET NAME correction. GET FILE = 'C:\temp\master_02012012.sav'. SORT CASES BY id. UPDATE /FILE = * /FILE = correction /IN = corrected /BY id. EXECUTE. set mprint = on. Dataset close all. *//////////////////////////////////. Define !UPD (datu1 = !tokens(1) /datu2 = !tokens(1) /datu3 = !tokens(1) /manam = !charend ( '/' ) /konam = !charend ( '/' )). get file = !quote( !concat( !konam,!datu2,'.sav')). sort cases by id. sav out = !quote( !concat( !konam,!datu2,'.sav')). dataset name correction. list. get file = !quote( !concat( !manam,!datu1,'.sav')). sort cases by id. sav out = !quote( !concat( !manam,!datu1,'.sav')). list. UPDATE /FILE = * /FILE = correction /IN = !concat('korr',!datu3) /BY id. EXECUTE. sav out = !quote( !concat( !manam,!datu3,'.sav')). list. Dataset close all. !EndDefine. *//////////////////////////////////. !UPD Datu1 = 02012012 Datu2 = 02012012 Datu3 = 03022012 manam = C:\temp\master_ / konam = C:\temp\korrektur_ / . ===================== 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
|
This rewrite works for my ancient version
(no support for DATASET NAME so using filename instead of DATASET NAME). I notice a *DISCREPANCY* between the name of the file you created at the beginning of your code and what you used in your macro call. sav out = 'C:\temp\correction_02022012.sav'. vs C:\temp\korrektur_ (C:\temp\korrektur_02022012.sav') after the !CONCAT. Define !UPD (datu1 = !tokens(1) /datu2 = !tokens(1) /datu3 = !tokens(1) /manam = !charend ( '/' ) /konam = !charend ( '/' )). !LET !FILE1=!quote( !concat( !manam,!datu1,'.sav')). !LET !FILE2=!quote( !concat( !konam,!datu2,'.sav')). !LET !FILE3=!quote( !concat( !manam,!datu3,'.sav')). get file = !FILE2 . sort cases by id. LIST. SAVE OUTFILE = !FILE2 . GET FILE = !FILE1. SORT CASES BY id. SAVE OUTFILE = !FILE1. LIST. UPDATE /FILE = * /FILE = !FILE2 /IN = !concat('korr',!datu3) /BY id. EXECUTE. SAVE OUTFILE = !FILE3 . LIST. !EndDefine. *//////////////////////////////////. SET MPRINT ON. SET PRINTBACK ON. !UPD Datu1 = 02012012 Datu2 = 02022012 Datu3 = 03022012 manam = C:\temp\master_ / konam = C:\temp\correction_ / .
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 Michael Zaengle
On Thu, 2 Feb 2012 10:48:42 -0800, David Marso <[hidden email]>
wrote: Hallo David, Thank you very mauch for your help. The path name is not the problem. I tanslated the macro into English before posting it and forgot to translate "korrektur_". Your macro works fine, but I still don't understand why in my version all values of th IN-variable turn up to be "1". Michael >This rewrite works for my ancient version >(no support for DATASET NAME so using filename instead of DATASET NAME). >I notice a *DISCREPANCY* between the name of the file you created at the >beginning of your code and what you used in your macro call. >sav out = 'C:\temp\correction_02022012.sav'. >vs C:\temp\korrektur_ >(C:\temp\korrektur_02022012.sav') after the !CONCAT. > >Define !UPD (datu1 = !tokens(1) > /datu2 = !tokens(1) > /datu3 = !tokens(1) > /manam = !charend ( '/' ) > /konam = !charend ( '/' )). >!LET !FILE1=!quote( !concat( !manam,!datu1,'.sav')). >!LET !FILE2=!quote( !concat( !konam,!datu2,'.sav')). >!LET !FILE3=!quote( !concat( !manam,!datu3,'.sav')). > > >get file = !FILE2 . >sort cases by id. >LIST. >SAVE OUTFILE = !FILE2 . >GET FILE = !FILE1. >SORT CASES BY id. >SAVE OUTFILE = !FILE1. >LIST. >UPDATE > /FILE = * > /FILE = !FILE2 > /IN = !concat('korr',!datu3) > /BY id. >EXECUTE. >SAVE OUTFILE = !FILE3 . >LIST. >!EndDefine. >*//////////////////////////////////. >SET MPRINT ON. >SET PRINTBACK ON. >!UPD Datu1 = 02012012 Datu2 = 02022012 Datu3 = 03022012 > manam = C:\temp\master_ / konam = C:\temp\correction_ / . > > >Michael Zaengle wrote >> >> Hello listers, >> >> Topic: UPDATE. >> The macro below (!UPD) does not produce the correct IN-variable. >> All cases of the updated master sample show values of "1". >> Why? >> Michael >> >> data list list / id (f2) v2 (F2) v3 (Edate11). >> begin data. >> 1 22 12/10/11 >> 2 20 20/9/10 >> 3 18 18/6/10 >> 4 17 30/7/11 >> 5 44 17/4/10 >> 6 16 1/1/11 >> 7 18 30/12/11 >> 8 22 14/10/10 >> 9 32 20/9/11 >> 10 33 17/2/10 >> end data. >> list. >> sav out = 'C:\temp\master_02012012.sav'. >> data list list / id (f2) v2 (F2) v3 (Edate11). >> begin data. >> 1 22 10/10/11 >> 6 16 21/1/11 >> 8 22 16/10/10 >> 10 23 17/2/11 >> end data. >> list. >> sav out = 'C:\temp\correction_02022012.sav'. >> get file = 'C:\temp\correction_02022012.sav'. >> SORT CASE BY id. >> DATASET NAME correction. >> GET FILE = 'C:\temp\master_02012012.sav'. >> SORT CASES BY id. >> UPDATE /FILE = * >> /FILE = correction >> /IN = corrected >> /BY id. >> EXECUTE. >> set mprint = on. >> Dataset close all. >> *//////////////////////////////////. >> Define !UPD (datu1 = !tokens(1) >> /datu2 = !tokens(1) >> /datu3 = !tokens(1) >> /manam = !charend ( '/' ) >> /konam = !charend ( '/' )). >> get file = !quote( !concat( !konam,!datu2,'.sav')). >> sort cases by id. >> sav out = !quote( !concat( !konam,!datu2,'.sav')). >> dataset name correction. >> list. >> get file = !quote( !concat( !manam,!datu1,'.sav')). >> sort cases by id. >> sav out = !quote( !concat( !manam,!datu1,'.sav')). >> list. >> UPDATE >> /FILE = * >> /FILE = correction >> /IN = !concat('korr',!datu3) >> /BY id. >> EXECUTE. >> sav out = !quote( !concat( !manam,!datu3,'.sav')). >> list. >> Dataset close all. >> !EndDefine. >> *//////////////////////////////////. >> !UPD Datu1 = 02012012 Datu2 = 02012012 Datu3 = 03022012 >> manam = C:\temp\master_ / konam = C:\temp\korrektur_ / . >> >> ===================== >> 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 >> > > >-- >View this message in context: http://spssx- >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 |
Administrator
|
You should SET MPRINT ON PRINTBACK ON and examine the generated syntax.
These things NEVER have anything to do with macro specifically but the syntax which is run. N.B. The *ONLY* things I changed was the condensing of the !CONCATs into a single place and *MOST IMPORTANT* my version uses the *explicit file name* rather than the DATASET reference. Maybe that got FUBARed. Change that in your version and see if that works? My version does not support multiple data sets so I have no way to confirm. HTH, David --
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?" |
Free forum by Nabble | Edit this page |