Error in macros!

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Error in macros!

Juris Breidaks

Hey!

Can somebody to help solution for this problem.

I have macro in with need to include some new values from macro into macros.


define pinclu() "c:\juris\macros.sps" !end.

define !apint2()
 !do !np=1 !to !eva(!maks).
get file=!pathl36.
do if (npk=!np).
write out=!includ
 /"set err=off."
 /"define !gads() " gads " !end."
 /"define !men() " men " !end."
 /"define !reize() " reize " !end."
 /"define !nr() " nr " !end."
 /"set err=on.".
end if.
exe.
data list free /a(f1).
begin data.
end data.
include file=!includ.
include file=!pinclu.
 !doend.
 !end.
set err=on.


With best regards,
Juris
Reply | Threaded
Open this post in threaded view
|

Re: Error in macros!

Richard Ristow
At 12:13 PM 3/2/2009, Juris Breidaks wrote:

I have macro in with need to include some new values from macro into macros.

define pinclu() "c:\juris\macros.sps" !end.

define !apint2()
 !do !np=1 !to !eva(!maks).
get file=!pathl36.
do if (npk=!np).
write out=!includ
 /"set err=off."
 /"define !gads() " gads " !end."
 /"define !men() " men " !end."
 /"define !reize() " reize " !end."
 /"define !nr() " nr " !end."
 /"set err=on.".
end if.
exe.
data list free /a(f1).
begin data.
end data.
include file=!includ.
include file=!pinclu.
 !doend.
 !end.
set err=on.

The problem is those two include lines I've emphasized. You want them executed when the macro is run, to include the text you just wrote out to the file; but "INCLUDE" is executed when the code is first processed -- i.e., when the macro is defined. You're getting either the file without what you've written to it, or an error saying the file doesn't exist.

Inside your loop, write all the code to your "include" file, then include it once outside the macro, after invoking the macro.
===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Error in macros!

Albert-Jan Roskam
In reply to this post by Juris Breidaks
Hi!

-I would recommend to switch to Python. It's easier and infinitely more flexible.
-Is "!end" allowed? I'd say it's "!enddefine"
-You should use !if-!then-!ifend rather than DO IF.
-set mprint = on helps diagnosing problems.

Cheers!!
Albert-Jan



--- On Mon, 3/2/09, Juris Breidaks <[hidden email]> wrote:

> From: Juris Breidaks <[hidden email]>
> Subject: Error in macros!
> To: [hidden email]
> Date: Monday, March 2, 2009, 6:13 PM
> Hey!
>
> Can somebody to help solution for this problem.
>
> I have macro in with need to include some new values from
> macro into
> macros.
>
>
> define pinclu() "c:\juris\macros.sps"
> !end.
>
> define !apint2()
>  !do !np=1 !to !eva(!maks).
> get file=!pathl36.
> do if (npk=!np).
> write out=!includ
>  /"set err=off."
>  /"define !gads() " gads " !end."
>  /"define !men() " men " !end."
>  /"define !reize() " reize " !end."
>  /"define !nr() " nr " !end."
>  /"set err=on.".
> end if.
> exe.
> data list free /a(f1).
> begin data.
> end data.
> include file=!includ.
> include file=!pinclu.
>  !doend.
>  !end.
> set err=on.
>
>
> With best regards,
> Juris

=====================
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
Reply | Threaded
Open this post in threaded view
|

Error after DATASET CLOSE Hoofd.sav

Ruben Geert van den Berg
Dear all,
 
Could somebody please tell me why this is happening? This dataset is both open and activated.
 
DATASET CLOSE Hoofd.sav.
 

Warnings

Unrecognized dataset name Hoofd.sav.

This command is not executed.


 
 
Lots of TIA and best regards from the Netherlands!
 
Ruben v.d. Berg


Express yourself instantly with MSN Messenger! MSN Messenger
Reply | Threaded
Open this post in threaded view
|

Re: Error after DATASET CLOSE Hoofd.sav

Art Kendall
This may not be the cause of your problem, but it seems unusual to have this kind of string "Hoofd.sav.for" the file handle (nickname).
"Hoofd.sav." looks like part of the filespec (name in the OS).

click on the "windows" tab to see what files you have open.

Art

Ruben van den Berg wrote:
Dear all,
 
Could somebody please tell me why this is happening? This dataset is both open and activated.
 
DATASET CLOSE Hoofd.sav.
 

Warnings

Unrecognized dataset name Hoofd.sav.

This command is not executed.


 
 
Lots of TIA and best regards from the Netherlands!
 
Ruben v.d. Berg


Express yourself instantly with MSN Messenger! MSN Messenger
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Error after DATASET CLOSE Hoofd.sav

Art Kendall-2
Start SPSS.
click <help>
click <tutorials>
Click <working with multiple data sources>.

when done with that
click <help>
click <topics>
click <search>
type "dataset" in the edit box.

Art Kendall
Social Research Consultants


Ruben van den Berg wrote:
Dear Art,
 
You're right, I wasn't even aware of a data file being something else than a data set.
 
However, is there any way to open a data file, edit it, save it, close it and move to the next one? I'll have to do some similar editing on a number of data files, that's why I was asking.
 
TIA and best regards from the Netherlands!!





 

Date: Tue, 3 Mar 2009 07:32:05 -0500
From: [hidden email]
Subject: Re: Error after DATASET CLOSE Hoofd.sav
To: [hidden email]

This may not be the cause of your problem, but it seems unusual to have this kind of string "Hoofd.sav.for" the file handle (nickname).
"Hoofd.sav." looks like part of the filespec (name in the OS).

click on the "windows" tab to see what files you have open.

Art

Ruben van den Berg wrote:
Dear all,
 
Could somebody please tell me why this is happening? This dataset is both open and activated.
 
DATASET CLOSE Hoofd.sav.
 

Warnings

Unrecognized dataset name Hoofd.sav.

This command is not executed.


 
 
Lots of TIA and best regards from the Netherlands!
 
Ruben v.d. Berg


Express yourself instantly with MSN Messenger! MSN Messenger


See all the ways you can stay connected to friends and family