Use of cards instruction

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.

Use of cards instruction

Postby jonasdovern » Tue Jun 07, 2011 11:45 am

Can I really only use the cards instruction with the functions that are listed in the reference manual under the header "Applicability"?

What I would like is to use the @condition procedure within another procedure that I wrote. The number of constraints should be handled flexibel, therefor I need the cards instruction ...

I have something like (I only list the relevant lines):
Code: Select all
procedure newproc
  option integer constraints 1
  local integer icon
  local index varcon entrycon
  local vec[real] valuecon
 
  dim varcon(constraints) entrycon(constraints) valuecon(constraints)
  do i=1,constraints
     enter varcon(i) entrycon(i) valuecon(i)
  end do i

  /* Estimate a model 'olsmodel' here */

  list icon = 1 to constraints
  @condition(model=olsmodel,from=ftime,steps=fsteps,nosimulate,results=olsfcasts) constraints
  cards varcon(icon) entrycon(icon) valuecon(icon)



This works fine for constraints equal to 1, but not for more than 1 constraint.

If the use of cards is not possible here. Can I use any other approach?
jonasdovern
 
Posts: 68
Joined: Sat Apr 11, 2009 10:30 am

Re: Use of cards instruction

Postby moderator » Fri Jun 10, 2011 4:12 pm

Yes, it is true that the applicability of the CARDS instruction is limited to specific instructions, so I don't think that code will work as written.

I'd probably be tempted to just modify a copy of CONDITION.SRC to accept the input in a different way, for use with your procedure.

Otherwise, you could use OPEN to open a text file, a sequence of DISPLAY(UNIT=unitname) commands to generate the necessary procedure call and supplementary cards into that file, a CLOSE command to close the file, and then a SOURCE command to execute the generated commands. That has the disadvantage of needing to generate a temporary file somewhere, but should be simple to implement. Again, though, I'd probably look to modifying a version of CONDITION.SRC as a more elegant solution.

Regards,
Tom Maycock
Estima
moderator
Site Admin
 
Posts: 306
Joined: Thu Oct 19, 2006 4:33 pm

Re: Use of cards instruction

Postby jonasdovern » Wed Jul 13, 2011 2:43 am

Thanks Tom. (Sorry for the late reply; I was on holidays.) I guess I'll write a condition2.src in this case.

Are you thinking about making the cards indstruction more generally applicable? I think it is a very useful command for users that write a lot of more advanced procedures.
jonasdovern
 
Posts: 68
Joined: Sat Apr 11, 2009 10:30 am


Return to Help With Programming

Who is online

Users browsing this forum: No registered users and 1 guest