I have a macro that produces multiple graphs of histograms. It has variables labeled as 'col1', 'col2', etc. The macro expands from col1 to coln using the numbers concatenated with the name 'col'. I'm trying to adapt the macro to perform repeated scatterplots
with variables with string names. Here's a sample dataset and the macro I've adapted which does not work. Is there any way to make this work. The variable names are produced in matrix format. I could make them col1 to col5 for example. Is that necessary? Thanks
in advance for any help.
data list free / k bprs gaf gse ese (5f5.2).
begin data .
0.00 0.24 -0.05 -0.30 -0.49
0.05 0.23 -0.05 -0.29 -0.47
0.10 0.23 -0.06 -0.29 -0.45
0.15 0.23 -0.06 -0.28 -0.43
0.20 0.22 -0.06 -0.28 -0.42
0.25 0.22 -0.06 -0.27 -0.40
0.30 0.21 -0.06 -0.27 -0.39
0.35 0.21 -0.06 -0.26 -0.38
0.40 0.21 -0.06 -0.26 -0.37
0.45 0.20 -0.06 -0.26 -0.36
0.50 0.20 -0.06 -0.25 -0.35
0.55 0.20 -0.06 -0.25 -0.34
0.60 0.19 -0.06 -0.24 -0.33
0.65 0.19 -0.06 -0.24 -0.32
0.70 0.19 -0.06 -0.23 -0.32
0.75 0.18 -0.06 -0.23 -0.31
0.80 0.18 -0.06 -0.23 -0.30
0.85 0.18 -0.06 -0.22 -0.29
0.90 0.18 -0.06 -0.22 -0.29
0.95 0.17 -0.06 -0.21 -0.28
1.00 0.17 -0.06 -0.21 -0.28
end data.
DEFINE olaygraf (first !charend('/')/last !charend('/')) .
!DO !var=!first !TO !last .
GRAPH
/SCATTERPLOT(BIVAR)=k with !var
/MISSING=LISTWISE.
!doend .
!enddefine .
olaygraf first=bprs/last=ese .
Brian
|
!DO !var=!first !TO !last
needs numeric integer arguments !first and !last. Yours are strings (variable names). Use !DO !var !IN(!varlist) instead. 05.02.2020 2:35, Dates, Brian пишет:
===================== 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 |
In reply to this post by bdates
Hi, Brian, an index loop expects numbers as input - not variable names. Also there are some punctuation errors in your code. You can choose: * method 1. DEFINE olaygraf2 (!POSITIONAL !CMDEND) . PRESERVE. SET MPRINT = ON PRINTBACK = ON. !DO !var !IN (!1) GRAPH /SCATTERPLOT(BIVAR)=k with !var /MISSING=LISTWISE. !DOEND. RESTORE. !ENDDEFINE. olaygraf2 bprs gaf gse ese. * method 2. RENAME VARIABLES (bprs gaf gse ese = col1 col2 col3 col4). DEFINE olaygraf (first !charend('/')/last !charend('/')) . PRESERVE. SET MPRINT = ON PRINTBACK = ON. !DO !var = !first !TO !last GRAPH /SCATTERPLOT(BIVAR)=k with !CONCAT(col,!var) /MISSING=LISTWISE. !DOEND RESTORE. !ENDDEFINE. olaygraf first=1 /last = 4. Personally, I like method 1 more. Good luck! Mario Giesel Munich, Germany
Am Mittwoch, 5. Februar 2020, 06:31:13 MEZ hat Dates, Brian <[hidden email]> Folgendes geschrieben:
I have a macro that produces multiple graphs of histograms. It has variables labeled as 'col1', 'col2', etc. The macro expands from col1 to coln using the numbers concatenated with the name 'col'. I'm trying to adapt the macro to perform repeated scatterplots
with variables with string names. Here's a sample dataset and the macro I've adapted which does not work. Is there any way to make this work. The variable names are produced in matrix format. I could make them col1 to col5 for example. Is that necessary? Thanks
in advance for any help.
data list free / k bprs gaf gse ese (5f5.2).
begin data .
0.00 0.24 -0.05 -0.30 -0.49
0.05 0.23 -0.05 -0.29 -0.47
0.10 0.23 -0.06 -0.29 -0.45
0.15 0.23 -0.06 -0.28 -0.43
0.20 0.22 -0.06 -0.28 -0.42
0.25 0.22 -0.06 -0.27 -0.40
0.30 0.21 -0.06 -0.27 -0.39
0.35 0.21 -0.06 -0.26 -0.38
0.40 0.21 -0.06 -0.26 -0.37
0.45 0.20 -0.06 -0.26 -0.36
0.50 0.20 -0.06 -0.25 -0.35
0.55 0.20 -0.06 -0.25 -0.34
0.60 0.19 -0.06 -0.24 -0.33
0.65 0.19 -0.06 -0.24 -0.32
0.70 0.19 -0.06 -0.23 -0.32
0.75 0.18 -0.06 -0.23 -0.31
0.80 0.18 -0.06 -0.23 -0.30
0.85 0.18 -0.06 -0.22 -0.29
0.90 0.18 -0.06 -0.22 -0.29
0.95 0.17 -0.06 -0.21 -0.28
1.00 0.17 -0.06 -0.21 -0.28
end data.
DEFINE olaygraf (first !charend('/')/last !charend('/')) .
!DO !var=!first !TO !last .
GRAPH
/SCATTERPLOT(BIVAR)=k with !var
/MISSING=LISTWISE.
!doend .
!enddefine .
olaygraf first=bprs/last=ese .
Brian
|
Macro does not support the TO or ALL variable list conventions, but you can use the SPSSINC SELECT VARIABLES extension command for this (or any metadata-based selection) and use that macro in olaygraf. SPSSINC SELECT VARIABLES MACRONAME="!varlist" VARIABLES=a to z. On Wed, Feb 5, 2020 at 1:25 AM Mario Giesel <[hidden email]> wrote:
|
Thank-you Mario, Kirill, and Jon for your direction. I'll post my final syntax later today for those who might find it useful.
Take care.
Brian
From: SPSSX(r) Discussion <[hidden email]> on behalf of Jon Peck <[hidden email]>
Sent: Wednesday, February 5, 2020 12:25 PM To: [hidden email] <[hidden email]> Subject: Re: Macro for multiple variables with scatterplot Macro does not support the TO or ALL variable list conventions, but you can use the SPSSINC SELECT VARIABLES extension command for this (or any metadata-based selection) and use that macro in olaygraf.
SPSSINC SELECT VARIABLES MACRONAME="!varlist" VARIABLES=a to z.
On Wed, Feb 5, 2020 at 1:25 AM Mario Giesel <[hidden email]> wrote:
|
Hi, all.
As promised, here's the syntax for a macro that produces scatterplot overlays for any number of variables, the names for which are entered into the SPSSINC Select Variables...command line. The scatterplots are for another variable (in this case, k) with each
of the identified variables in !varlist.
SPSSINC SELECT VARIABLES MACRONAME="!varlist" VARIABLES=bprs to ese.
DEFINE olaygraf (varlist=!cmdend) .
!DO !var !in(!varlist) .
GRAPH
/SCATTERPLOT(overlay)=k with !var
/MISSING=LISTWISE.
!doend .
!enddefine .
olaygraf varlist=!varlist .
Thanks again, everyone.
Brian
From: Dates, Brian <[hidden email]>
Sent: Wednesday, February 5, 2020 12:37 PM To: Jon Peck <[hidden email]>; [hidden email] <[hidden email]> Subject: Re: Macro for multiple variables with scatterplot
Thank-you Mario, Kirill, and Jon for your direction. I'll post my final syntax later today for those who might find it useful.
Take care.
Brian
From: SPSSX(r) Discussion <[hidden email]> on behalf of Jon Peck <[hidden email]>
Sent: Wednesday, February 5, 2020 12:25 PM To: [hidden email] <[hidden email]> Subject: Re: Macro for multiple variables with scatterplot Macro does not support the TO or ALL variable list conventions, but you can use the SPSSINC SELECT VARIABLES extension command for this (or any metadata-based selection) and use that macro in olaygraf.
SPSSINC SELECT VARIABLES MACRONAME="!varlist" VARIABLES=a to z.
On Wed, Feb 5, 2020 at 1:25 AM Mario Giesel <[hidden email]> wrote:
|
An addition to yesterday's syntax. If you are producing an overlay graph within a pre-existing macro which has identified the variables, you can use the
graph syntax inside the sample macro below, which would allow the 'to' for a series of contiguous variables:
Define hypothetical (varlist=!charend('/')/otherstuff=!charend('/')) .
Blah..
Blah..
Etc.
graph
/scatterplot(overlay) k with !varlist
/MISSING=LISTWISE
/TITLE='Sample' .
!enddefine .
hypothetical varlist=var1 to varx/otherstuff=whatever .
Brian
From: Dates, Brian <[hidden email]>
Sent: Wednesday, February 5, 2020 3:32 PM To: Jon Peck <[hidden email]>; [hidden email] <[hidden email]> Subject: Re: Macro for multiple variables with scatterplot
Hi, all.
As promised, here's the syntax for a macro that produces scatterplot overlays for any number of variables, the names for which are entered into the SPSSINC Select Variables...command line. The scatterplots are for another variable (in this case, k) with each
of the identified variables in !varlist.
SPSSINC SELECT VARIABLES MACRONAME="!varlist" VARIABLES=bprs to ese.
DEFINE olaygraf (varlist=!cmdend) .
!DO !var !in(!varlist) .
GRAPH
/SCATTERPLOT(overlay)=k with !var
/MISSING=LISTWISE.
!doend .
!enddefine .
olaygraf varlist=!varlist .
Thanks again, everyone.
Brian
From: Dates, Brian <[hidden email]>
Sent: Wednesday, February 5, 2020 12:37 PM To: Jon Peck <[hidden email]>; [hidden email] <[hidden email]> Subject: Re: Macro for multiple variables with scatterplot
Thank-you Mario, Kirill, and Jon for your direction. I'll post my final syntax later today for those who might find it useful.
Take care.
Brian
From: SPSSX(r) Discussion <[hidden email]> on behalf of Jon Peck <[hidden email]>
Sent: Wednesday, February 5, 2020 12:25 PM To: [hidden email] <[hidden email]> Subject: Re: Macro for multiple variables with scatterplot Macro does not support the TO or ALL variable list conventions, but you can use the SPSSINC SELECT VARIABLES extension command for this (or any metadata-based selection) and use that macro in olaygraf.
SPSSINC SELECT VARIABLES MACRONAME="!varlist" VARIABLES=a to z.
On Wed, Feb 5, 2020 at 1:25 AM Mario Giesel <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |