Hi Dears
How do I create a loop that gives several other data.frames through a variable e.g TEMPORARY. SELECT IF (VAR EQ "4206").
SAVE TRANSLATE OUTFILE ="4206_GR.XLS"/TYPE =XLS /VERSION=8 /REPLACE /FIELDNAMES. Where VAR is one variable of my database and 4206 is string valor of the VAR.
My variable may have several outhers values. How I do one loop for this? Thanks Sérgio Henrique Almeida da Silva Junior
Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: (21) 68463637 |
Administrator
|
DEFINE - !ENDDEFINE
!DO -!DOEND !QUOTE --
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?" |
Administrator
|
In reply to this post by shasj
See my reply to your post at comp.soft-sys.stat.spss.
https://groups.google.com/forum/#!topic/comp.soft-sys.stat.spss/smOsVOyAKfM
--
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/). |
Thanks
I guess I was not clear. I need split my data.frame for one variable (codigo) e.g NEW FILE. DATASET CLOSE all. DATA LIST FREE / codigo (A5) age sex(A1). BEGIN DATA. "10001" 10 "F" "10001" 20 "M" "10002" 25 "M" "10002" 24 "F" "10005" 32 "F" "10005" 30 "M" "10007" 14 "M" "10007" 16 "F" "10007" 18 "M" END DATA. TEMPORARY. SELECT IF (codigo EQ "10001"). SAVE TRANSLATE OUTFILE ="c:/10001_GR.XLS"/TYPE =XLS /VERSION=8 /REPLACE /FIELDNAMES. I do it for each value of the variable codigo (may I several values), but I'd like run one macro that I do it only once. Thanks!!! |
Administrator
|
What part of Bruce's post doesn't cut the mustard?
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?" |
I don´t understand very well what you say!
But in the Bruce's post I understand that I say for my macro the values of the my variable. STLoop Vlist = "4206" "4207". Not? |
Administrator
|
Maybe a quick peek at the FM (fine manual) might illuminate?
Or some strong coffee, a cold shower or more sleep? --
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?" |
Dear David Marso The Bruce's post run fine. But I have to say for what values for split
see exemple below. I do it easily in the R software, but I need to do in SPSS too.
Thanks for your help! !DO !V !IN(!Vlist) !LET !F = !QUOTE(!CONCAT(!UNQUOTE(!V),"_GR.XLS")) TEMPORARY. SELECT IF (VAR EQ !V). SAVE TRANSLATE OUTFILE = !F /TYPE =XLS /VERSION=8
/REPLACE /FIELDNAMES. !DOEND !ENDDEFINE. SET mprint on. STLoop Vlist = "0004" "0388" "0514" "0973" "1545" "1940" "2178" "2273" "2628" "3211" "3291".
SET mprint off. 2013/6/24 David Marso [via SPSSX Discussion] <[hidden email]> Maybe a quick peek at the FM (fine manual) might illuminate? Sérgio Henrique Almeida da Silva Junior
Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: (21) 68463637 |
Administrator
|
It might help if we include here your most recent post to the usenet newsgroup. (This mailing list is far more active these days than the newsgroup.) Here it is.
--- shasj's post to comp.soft-sys.stat.spss --- I guess I was not clear. I need split my data.frame for one variable (codigo) e.g NEW FILE. DATASET CLOSE all. DATA LIST FREE / codigo (A5) age sex(A1). BEGIN DATA. "10001" 10 "F" "10001" 20 "M" "10002" 25 "M" "10002" 24 "F" "10005" 32 "F" "10005" 30 "M" "10007" 14 "M" "10007" 16 "F" "10007" 18 "M" END DATA. TEMPORARY. SELECT IF (codigo EQ "10001"). SAVE TRANSLATE OUTFILE ="c:/10001_GR.XLS"/TYPE =XLS /VERSION=8 /REPLACE /FIELDNAMES. I do it for each value of the variable codigo (may I several values), but I'd like run one macro that I do it only once.
--
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/). |
All possible value of Var! 2013/6/24 Bruce Weaver [via SPSSX Discussion] <[hidden email]> It might help if we include here your most recent post to the usenet newsgroup. (This mailing list is far more active these days than the newsgroup.) Here it is. Sérgio Henrique Almeida da Silva Junior
Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: (21) 68463637 |
Administrator
|
This can probably be done via Python. But you could also use a native SPSS approach that some list members describe as a "horrible hack". ;-)
NEW FILE. DATASET CLOSE all. DATA LIST FREE / codigo (A5) age(F2.0) sex(A1). BEGIN DATA. "10001" 10 "F" "10001" 20 "M" "10002" 25 "M" "10002" 24 "F" "10005" 32 "F" "10005" 30 "M" "10007" 14 "M" "10007" 16 "F" "10007" 18 "M" END DATA. SORT CASES by codigo. MATCH FILES file = * / BY codigo / FIRST = FirstRec. EXECUTE. * Write commands to a syntax file. DO IF FirstRec. - WRITE OUTFILE "C:\TEMP\HorribleHack.SPS" / "TEMPORARY." / "SELECT IF (codigo EQ ","'",codigo"'",")." / "SAVE TRANSLATE OUTFILE ='c:\Temp\",codigo,"_GR.XLS'/TYPE =XLS /VERSION=8/REPLACE/FIELDNAMES.". END IF. EXECUTE. * Now insert that syntax file. INSERT FILE = "C:\TEMP\HorribleHack.SPS". * Clean up the junk . ERASE FILE = "C:\TEMP\HorribleHack.SPS". * ---------------------------------------------- . Contents of the resulting Excel files are: codigo age sex FirstRec 10001 10 F 1 10001 20 M 0 codigo age sex FirstRec 10002 25 M 1 10002 24 F 0 codigo age sex FirstRec 10005 32 F 1 10005 30 M 0 codigo age sex FirstRec 10007 14 M 1 10007 16 F 0 10007 18 M 0 HTH.
--
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/). |
Fine! Thanks very much! 2013/6/25 Bruce Weaver [via SPSSX Discussion] <[hidden email]> This can probably be done via Python. But you could also use a native SPSS approach that some list members describe as a "horrible hack". ;-) Sérgio Henrique Almeida da Silva Junior
Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: (21) 68463637 |
Administrator
|
If you don't want all of the stuff in HorribleHack.SPS echoed in your output window, you could add some SET commands, like this:
SET PRINTBACK = OFF. /* Suppress output. INSERT FILE = "C:\TEMP\HorribleHack.SPS". SET PRINTBACK = ON. /* Turn output back on.
--
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/). |
Hi,
Hi, I'm away on leave, and will return to work on August 1st. I will not have regular access to my email account while away, and will endeavour to return your emails shortly after my return. If you have urgent queries regarding T1 HPS301/781, please contact Dr Melissa Weinberg (melissaw@...) Cheers, Matt. |
In reply to this post by Bruce Weaver
Thanks again!
I install the python plugin in SPSS and run the script SPSSINC SPLIT DATASET SPLITVAR=VAR /OUTPUT DIRECTORY= DELETECONTENTS=NO
/OPTIONS NAMES=VALUES PRINTLIST=YES. but it save my data.frame in *SAV and I need save it in XLS. 2013/6/26 Bruce Weaver [via SPSSX Discussion] <[hidden email]> If you don't want all of the stuff in HorribleHack.SPS echoed in your output window, you could add some SET commands, like this: Sérgio Henrique Almeida da Silva Junior
Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: (21) 68463637 |
I posted an answer to this on another site
where you duplicated this post.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: shasj <[hidden email]> To: [hidden email], Date: 06/26/2013 04:46 PM Subject: Re: [SPSSX-L] SELECT IF LOOP Sent by: "SPSSX(r) Discussion" <[hidden email]> Thanks again! I install the python plugin in SPSS and run the script SPSSINC SPLIT DATASET SPLITVAR=VAR /OUTPUT DIRECTORY= DELETECONTENTS=NO /OPTIONS NAMES=VALUES PRINTLIST=YES. but it save my data.frame in *SAV and I need save it in XLS. 2013/6/26 Bruce Weaver [via SPSSX Discussion] <[hidden email]> If you don't want all of the stuff in HorribleHack.SPS echoed in your output window, you could add some SET commands, like this: SET PRINTBACK = OFF. /* Suppress output. INSERT FILE = "C:\TEMP\HorribleHack.SPS". SET PRINTBACK = ON. /* Turn output back on. shasj wrote Fine! Thanks very much! 2013/6/25 Bruce Weaver [via SPSSX Discussion] < [hidden email]> > This can probably be done via Python.  But you could also use a native > SPSS approach that some list members describe as a "horrible hack".  ;-) > > NEW FILE. > DATASET CLOSE all. > DATA LIST FREE / >  codigo (A5)  age(F2.0) sex(A1). > BEGIN DATA. > "10001" 10 "F" > "10001" 20  "M" > "10002" 25  "M" > "10002" 24  "F" > "10005" 32  "F" > "10005" 30  "M" > "10007" 14  "M" > "10007" 16  "F" > "10007" 18  "M" > END DATA. > > SORT CASES by codigo. > MATCH FILES file = * / BY codigo / FIRST = FirstRec. > EXECUTE. > > * Write commands to a syntax file. > > DO IF FirstRec. > - WRITE OUTFILE "C:\TEMP\HorribleHack.SPS" / >  "TEMPORARY." / >  "SELECT IF (codigo EQ ","'",codigo"'",")." / >  "SAVE TRANSLATE OUTFILE ='c:\Temp\",codigo,"_GR.XLS'/TYPE =XLS > /VERSION=8/REPLACE/FIELDNAMES.". > END IF. > EXECUTE. > > * Now insert that syntax file. > > INSERT FILE = "C:\TEMP\HorribleHack.SPS". > > * Clean up the junk . > > ERASE FILE = "C:\TEMP\HorribleHack.SPS". > > * ---------------------------------------------- . > > Contents of the resulting Excel files are: > > codigo age sex FirstRec > 10001 10 F 1 > 10001 20 M 0 > > codigo age sex FirstRec > 10002 25 M 1 > 10002 24 F 0 > > codigo age sex FirstRec > 10005 32 F 1 > 10005 30 M 0 > > codigo age sex FirstRec > 10007 14 M 1 > 10007 16 F 0 > 10007 18 M 0 > > HTH. > > > shasj wrote > All possible value of Var! > > > 2013/6/24 Bruce Weaver [via SPSSX Discussion] < > [hidden email] <http://user/SendEmail.jtp?type=node&node=5720886&i=0>> > > > It might help if we include here your most recent post to the usenet > > newsgroup.  (This mailing list is far more active these days than the > > newsgroup.)  Here it is. > > > > *--- shasj's post to comp.soft-sys.stat.spss ---* > > > > I guess I was not clear. I need split my data.frame for one variable > > (codigo) > > > > e.g > > > > NEW FILE. > > DATASET CLOSE all. > > DATA LIST FREE / > >  codigo (A5)  age sex(A1). > > BEGIN DATA. > > "10001" 10 "F" > > "10001" 20  "M" > > "10002" 25  "M" > > "10002" 24  "F" > > "10005" 32  "F" > > "10005" 30  "M" > > "10007" 14  "M" > > "10007" 16  "F" > > "10007" 18  "M" > > END DATA. > > > > TEMPORARY. > > SELECT IF (codigo EQ "10001"). > > SAVE TRANSLATE OUTFILE ="c:/10001_GR.XLS"/TYPE =XLS > > /VERSION=8 > > /REPLACE > > /FIELDNAMES. > > > > > > I do it for each value of the variable codigo (may I several values), > but > > I'd like run one macro that I do it only once. > > > > > > > > shasj wrote > > Dear David Marso > > > > The Bruce's post run fine. But I have to say for what values for split > > > > see exemple below. > > > > I do it easily in the R software, but I need to do in SPSS too. > > > > Thanks for your help! > > > > !DO !V !IN(!Vlist) > > !LET !F = !QUOTE(!CONCAT(!UNQUOTE(!V),"_GR.XLS")) > > TEMPORARY. > > SELECT IF (VAR EQ !V). > > SAVE TRANSLATE OUTFILE = !F /TYPE =XLS > >  /VERSION=8 > >  /REPLACE > >  /FIELDNAMES. > > > > !DOEND > > > > !ENDDEFINE. > > > > > > SET mprint on. > > STLoop Vlist = "0004" "0388" "0514" "0973" "1545" "1940" "2178" "2273" > > "2628" "3211" "3291". > > SET mprint off. > > > > > > > > 2013/6/24 David Marso [via SPSSX Discussion] < > > [hidden email] <http://user/SendEmail.jtp?type=node&node=5720871&i=0>> > > > > > Maybe a quick peek at the FM (fine manual) might illuminate? > > > Or some strong coffee, a cold shower or more sleep? > > > -- > > > > > > shasj wrote > > > I don´t understand very well what you say! > > > > > > But in the  Bruce's post I understand that I say for my macro the > values > > > of the my variable. > > > > > > STLoop Vlist = "4206" "4207". > > > > > > Not? > > > > > >  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?" > > > > > > > > > ------------------------------ > > >  If you reply to this email, your message will be added to the > > discussion > > > below: > > > > > > > > > http://spssx-discussion.1045642.n5.nabble.com/SELECT-IF-LOOP-tp5720860p5720867.html > > >  To unsubscribe from SELECT IF LOOP, click here< > > > > > > > . > > > NAML< > > > http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml > >< > http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml%3E><http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml%3E%3E> > > > > > > > > > > > > -- > > Sérgio Henrique Almeida da Silva Junior > > Doutorando em Epidemiologia em Saúde Pública > > Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ > > http://lattes.cnpq.br/1611345552843383 > > Tel: <a href="tel:%2821%29%2068463637" value="+12168463637" target="_blank">(21) 68463637 > > http://www.linkedin.com/profile/view?id=250437145&trk=tab_pro > > > >  -- > > Bruce Weaver > > [hidden email] <http://user/SendEmail.jtp?type=node&node=5720886&i=1> > > > http://sites.google.com/a/lakeheadu.ca/bweaver/ > > > > "When all else fails, RTFM." > > > > *NOTE: My Hotmail account is not monitored regularly. > > To send me an e-mail, please use the address shown above. > > * > > > > > > ------------------------------ > >  If you reply to this email, your message will be added to the > discussion > > below: > > > > > http://spssx-discussion.1045642.n5.nabble.com/SELECT-IF-LOOP-tp5720860p5720871.html > >  To unsubscribe from SELECT IF LOOP, click here< > > > . > > NAML< > http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml><http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml%3E> > > > > > > -- > Sérgio Henrique Almeida da Silva Junior > Doutorando em Epidemiologia em Saúde Pública > Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ > http://lattes.cnpq.br/1611345552843383 > Tel: <a href="tel:%2821%29%2068463637" value="+12168463637" target="_blank">(21) 68463637 > http://www.linkedin.com/profile/view?id=250437145&trk=tab_pro > >  -- > Bruce Weaver > [hidden email] > http://sites.google.com/a/lakeheadu.ca/bweaver/ > > "When all else fails, RTFM." > > *NOTE: My Hotmail account is not monitored regularly. > To send me an e-mail, please use the address shown above. > * > > > ------------------------------ >  If you reply to this email, your message will be added to the discussion > below: > > http://spssx-discussion.1045642.n5.nabble.com/SELECT-IF-LOOP-tp5720860p5720886.html >  To unsubscribe from SELECT IF LOOP, click here< > . > NAML<http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- Sérgio Henrique Almeida da Silva Junior Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: <a href="tel:%2821%29%2068463637" value="+12168463637" target="_blank">(21) 68463637 http://www.linkedin.com/profile/view?id=250437145&trk=tab_pro -- If you reply to this email, your message will be added to the discussion below: http://spssx-discussion.1045642.n5.nabble.com/SELECT-IF-LOOP-tp5720860p5720896.html To unsubscribe from SELECT IF LOOP, click here. NAML -- Sérgio Henrique Almeida da Silva Junior Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: (21) 68463637 http://www.linkedin.com/profile/view?id=250437145&trk=tab_pro View this message in context: Re: SELECT IF LOOP Sent from the SPSSX Discussion mailing list archive at Nabble.com. |
Administrator
|
Could you post the link to it here, Jon?
--
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/). |
Hello, |
In reply to this post by Bruce Weaver
Here is the thread.
http://www.linkedin.com/groups/SELECT-IF-LOOP-44190.S.252475331?view=&srchtype=discussedNews&gid=44190&item=252475331&type=member&trk=eml-anet_dig-b_pd-pmt-cn&fromEmail=&ut=1fdavSFQrm05Q1 Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Bruce Weaver <[hidden email]> To: [hidden email], Date: 06/27/2013 06:25 AM Subject: Re: [SPSSX-L] SELECT IF LOOP Sent by: "SPSSX(r) Discussion" <[hidden email]> Could you post the link to it here, Jon? Jon K Peck wrote > I posted an answer to this on another site where you duplicated this post. > > > Jon Peck (no "h") aka Kim > Senior Software Engineer, IBM > peck@.ibm > phone: 720-342-5621 > > > > > From: shasj < > sergio.edfisica@ > > > To: > SPSSX-L@.uga > , > Date: 06/26/2013 04:46 PM > Subject: Re: [SPSSX-L] SELECT IF LOOP > Sent by: "SPSSX(r) Discussion" < > SPSSX-L@.uga > > > > > > Thanks again! > > I install the python plugin in SPSS and run the script > > SPSSINC SPLIT DATASET SPLITVAR=VAR > /OUTPUT DIRECTORY= DELETECONTENTS=NO > /OPTIONS NAMES=VALUES PRINTLIST=YES. > > but it save my data.frame in *SAV and I need save it in XLS. > > > > 2013/6/26 Bruce Weaver [via SPSSX Discussion] <[hidden email]> > If you don't want all of the stuff in HorribleHack.SPS echoed in your > output window, you could add some SET commands, like this: > > SET PRINTBACK = OFF. /* Suppress output. > > INSERT FILE = "C:\TEMP\HorribleHack.SPS". > SET PRINTBACK = ON. /* Turn output back on. > > > shasj wrote > Fine! > > Thanks very much! > > > 2013/6/25 Bruce Weaver [via SPSSX Discussion] < > [hidden email]> > >> This can probably be done via Python.  But you could also use a native >> SPSS approach that some list members describe as a "horrible hack". >  ;-) >> >> NEW FILE. >> DATASET CLOSE all. >> DATA LIST FREE / >>  codigo (A5)  age(F2.0) sex(A1). >> BEGIN DATA. >> "10001" 10 "F" >> "10001" 20  "M" >> "10002" 25  "M" >> "10002" 24  "F" >> "10005" 32  "F" >> "10005" 30  "M" >> "10007" 14  "M" >> "10007" 16  "F" >> "10007" 18  "M" >> END DATA. >> >> SORT CASES by codigo. >> MATCH FILES file = * / BY codigo / FIRST = FirstRec. >> EXECUTE. >> >> * Write commands to a syntax file. >> >> DO IF FirstRec. >> - WRITE OUTFILE "C:\TEMP\HorribleHack.SPS" / >>  "TEMPORARY." / >>  "SELECT IF (codigo EQ ","'",codigo"'",")." / >>  "SAVE TRANSLATE OUTFILE ='c:\Temp\",codigo,"_GR.XLS'/TYPE =XLS >> /VERSION=8/REPLACE/FIELDNAMES.". >> END IF. >> EXECUTE. >> >> * Now insert that syntax file. >> >> INSERT FILE = "C:\TEMP\HorribleHack.SPS". >> >> * Clean up the junk . >> >> ERASE FILE = "C:\TEMP\HorribleHack.SPS". >> >> * ---------------------------------------------- . >> >> Contents of the resulting Excel files are: >> >> codigo age sex FirstRec >> 10001 10 F 1 >> 10001 20 M 0 >> >> codigo age sex FirstRec >> 10002 25 M 1 >> 10002 24 F 0 >> >> codigo age sex FirstRec >> 10005 32 F 1 >> 10005 30 M 0 >> >> codigo age sex FirstRec >> 10007 14 M 1 >> 10007 16 F 0 >> 10007 18 M 0 >> >> HTH. >> >> >> shasj wrote >> All possible value of Var! >> >> >> 2013/6/24 Bruce Weaver [via SPSSX Discussion] < >> [hidden email] >> <http://user/SendEmail.jtp?type=node&node=5720886&i=0>> >> > >> > It might help if we include here your most recent post to the usenet >> > newsgroup.  (This mailing list is far more active these days than the > >> > newsgroup.)  Here it is. >> > >> > *--- shasj's post to comp.soft-sys.stat.spss ---* >> > >> > I guess I was not clear. I need split my data.frame for one variable >> > (codigo) >> > >> > e.g >> > >> > NEW FILE. >> > DATASET CLOSE all. >> > DATA LIST FREE / >> >  codigo (A5)  age sex(A1). >> > BEGIN DATA. >> > "10001" 10 "F" >> > "10001" 20  "M" >> > "10002" 25  "M" >> > "10002" 24  "F" >> > "10005" 32  "F" >> > "10005" 30  "M" >> > "10007" 14  "M" >> > "10007" 16  "F" >> > "10007" 18  "M" >> > END DATA. >> > >> > TEMPORARY. >> > SELECT IF (codigo EQ "10001"). >> > SAVE TRANSLATE OUTFILE ="c:/10001_GR.XLS"/TYPE =XLS >> > /VERSION=8 >> > /REPLACE >> > /FIELDNAMES. >> > >> > >> > I do it for each value of the variable codigo (may I several values), >> but >> > I'd like run one macro that I do it only once. >> > >> > >> > >> > shasj wrote >> > Dear David Marso >> > >> > The Bruce's post run fine. But I have to say for what values for split > >> > >> > see exemple below. >> > >> > I do it easily in the R software, but I need to do in SPSS too. >> > >> > Thanks for your help! >> > >> > !DO !V !IN(!Vlist) >> > !LET !F = !QUOTE(!CONCAT(!UNQUOTE(!V),"_GR.XLS")) >> > TEMPORARY. >> > SELECT IF (VAR EQ !V). >> > SAVE TRANSLATE OUTFILE = !F /TYPE =XLS >> >  /VERSION=8 >> >  /REPLACE >> >  /FIELDNAMES. >> > >> > !DOEND >> > >> > !ENDDEFINE. >> > >> > >> > SET mprint on. >> > STLoop Vlist = "0004" "0388" "0514" "0973" "1545" "1940" "2178" "2273" > >> > "2628" "3211" "3291". >> > SET mprint off. >> > >> > >> > >> > 2013/6/24 David Marso [via SPSSX Discussion] < >> > [hidden email] >> <http://user/SendEmail.jtp?type=node&node=5720871&i=0>> > >> > >> > > Maybe a quick peek at the FM (fine manual) might illuminate? >> > > Or some strong coffee, a cold shower or more sleep? >> > > -- >> > > >> > > shasj wrote >> > > I don´t understand very well what you say! >> > > >> > > But in the  Bruce's post I understand that I say for my macro the >> values >> > > of the my variable. >> > > >> > > STLoop Vlist = "4206" "4207". >> > > >> > > Not? >> > > >> > >  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?" >> > > >> > > >> > > ------------------------------ >> > >  If you reply to this email, your message will be added to the >> > discussion >> > > below: >> > > >> > > >> > >> > http://spssx-discussion.1045642.n5.nabble.com/SELECT-IF-LOOP-tp5720860p5720867.html >> > >  To unsubscribe from SELECT IF LOOP, click here< >> > >> >> >> > > . >> > > NAML< >> > >> > http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml > >> >< >> > http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml%3E >>< > http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml%3E%3E> > >> >> > > >> > >> > >> > >> > -- >> > Sérgio Henrique Almeida da Silva Junior >> > Doutorando em Epidemiologia em Saúde Pública >> > Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ >> > http://lattes.cnpq.br/1611345552843383 >> > Tel: > (21) 68463637 >> > http://www.linkedin.com/profile/view?id=250437145&trk=tab_pro >> > >> >  -- >> > Bruce Weaver >> > [hidden email] >> <http://user/SendEmail.jtp?type=node&node=5720886&i=1> > >> >> > http://sites.google.com/a/lakeheadu.ca/bweaver/ >> > >> > "When all else fails, RTFM." >> > >> > *NOTE: My Hotmail account is not monitored regularly. >> > To send me an e-mail, please use the address shown above. >> > * >> > >> > >> > ------------------------------ >> >  If you reply to this email, your message will be added to the >> discussion >> > below: >> > >> > >> > http://spssx-discussion.1045642.n5.nabble.com/SELECT-IF-LOOP-tp5720860p5720871.html >> >  To unsubscribe from SELECT IF LOOP, click here< >> >> > . >> > NAML< >> > http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml >>< > http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml%3E> > >> > > >> >> >> >> -- >> Sérgio Henrique Almeida da Silva Junior >> Doutorando em Epidemiologia em Saúde Pública >> Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ >> http://lattes.cnpq.br/1611345552843383 >> Tel: <tel:%2821%29%2068463637> > (21) 68463637 >> http://www.linkedin.com/profile/view?id=250437145&trk=tab_pro >> >>  -- >> Bruce Weaver >> [hidden email] >> http://sites.google.com/a/lakeheadu.ca/bweaver/ >> > >> "When all else fails, RTFM." >> >> *NOTE: My Hotmail account is not monitored regularly. >> To send me an e-mail, please use the address shown above. >> * >> >> >> ------------------------------ >>  If you reply to this email, your message will be added to the > discussion >> below: >> >> > http://spssx-discussion.1045642.n5.nabble.com/SELECT-IF-LOOP-tp5720860p5720886.html > >>  To unsubscribe from SELECT IF LOOP, click here< > . >> NAML< > http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > >> > > > > -- > Sérgio Henrique Almeida da Silva Junior > Doutorando em Epidemiologia em Saúde Pública > Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ > http://lattes.cnpq.br/1611345552843383 > Tel: <tel:%2821%29%2068463637> > (21) 68463637 > http://www.linkedin.com/profile/view?id=250437145&trk=tab_pro > -- > Bruce Weaver > [hidden email] > http://sites.google.com/a/lakeheadu.ca/bweaver/ > > "When all else fails, RTFM." > > NOTE: My Hotmail account is not monitored regularly. > To send me an e-mail, please use the address shown above. > > > > If you reply to this email, your message will be added to the discussion > below: > http://spssx-discussion.1045642.n5.nabble.com/SELECT-IF-LOOP-tp5720860p5720896.html > > To unsubscribe from SELECT IF LOOP, click here. > NAML > > > > -- > Sérgio Henrique Almeida da Silva Junior > Doutorando em Epidemiologia em Saúde Pública > Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ > http://lattes.cnpq.br/1611345552843383 > Tel: (21) 68463637 > http://www.linkedin.com/profile/view?id=250437145&trk=tab_pro > > View this message in context: Re: SELECT IF LOOP > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > <tel:%2821%29%2068463637> ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SELECT-IF-LOOP-tp5720860p5720912.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 |
Free forum by Nabble | Edit this page |