Help using Base SAS procedures

MACRO Explanation

Reply
Regular Contributor
Posts: 161

MACRO Explanation

Hello Experts,

I have 2 questions regarding Macro:

1) when we assign replication to a set of codes, is there a common problem with these replication going threw the codes differently. Ex: I have 3 replication and the first 2 skips a step while the last one goes threw the whole thing as it supposed to. Is there a common obvious mistake that I should look for

2) when we have a macro within macro with for example 100 iteration. what happens?

do SAS goes threw each macro separately or behaves like a loop, finishing the macro within before ending the macro outside


Thank you for your help
R.A.G.
Trusted Advisor
Posts: 2,115

Re: MACRO Explanation

I don't understand question 1. an example would help.

For question 2, by specifying OPTIONS MACROGEN; you can see exactly the code that is generated by a macro (and by a macro within a macro).
Regular Contributor
Posts: 161

Re: MACRO Explanation

Thank you Doc,

Maybe this will help, I am getting these errors:

first error:
MPRINT(CREATEMPLUSINPUT): * Item by threshold data for writing item-based commands;
MPRINT(CREATEMPLUSINPUT): DATA itembythresh;
MPRINT(CREATEMPLUSINPUT): SET kernel;
MPRINT(CREATEMPLUSINPUT): RUN;
ERROR: You cannot open WORK.ITEMBYTHRESH.DATA for output access with member-level control
because WORK.ITEMBYTHRESH.DATA is in use by you in resource environment DMS Process.
NOTE: The SAS System stopped processing this step because of errors.

2nd ERROR:
SYMBOLGEN: Macro variable COMMANDFILE resolves to CDM_1
NOTE: Line generated by the invoked macro "WRITEMPLUS".
3 * Name of Mplus file to be written with returns and breaks; FILE
----
180
3 ! "c:\CDM1\&commandfile..inp"; * Mplus TITLE command; PUT @1 "TITLE: ! Section
3 ! that appears in header of output file"; PUT @5
ERROR 180-322: Statement is not valid or it is used out of proper order.
SAS Super FREQ
Posts: 8,863

Re: MACRO Explanation

Regular Contributor
Posts: 161

Re: MACRO Explanation

Posted in reply to Cynthia_sas
Hi Cynthia,

It does relate to the previous issue in a way.

It all comes from the same MACRO but the problems are different.

Thank you
Super User
Posts: 11,343

Re: MACRO Explanation

The error: ERROR: You cannot open WORK.ITEMBYTHRESH.DATA for output access with member-level control
because WORK.ITEMBYTHRESH.DATA is in use by you in resource environment DMS Process.

means that some other program has the output data set open and/or locked so the referenced data step can't use it. It is likely you opened the data set to see the results previously and didn't close it from the table view.
Regular Contributor
Posts: 161

Re: MACRO Explanation

Thank you
that make sense and I am sure you are right. B/C when I have 1 iteration it works fine the problem starts when I have more than 1 iteration which from what you've said means the first iteration opens it and does not close it. How do I close these three files. I have tried the following and still does not work:

%let ITEMBYTHRESH=%sysfunc(close(&.ITEMBYTHRESH));
I have 3 of these files with different names

Thank you
Ask a Question
Discussion stats
  • 6 replies
  • 1433 views
  • 0 likes
  • 4 in conversation