<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro/vbscript breaking down? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Macro-vbscript-breaking-down/m-p/12942#M2827</link>
    <description>Hi &lt;BR /&gt;
&lt;BR /&gt;
My VBS knowledge is rather basic but if I get this right then you're starting 70 EG sessions more or less in parallel. &lt;BR /&gt;
May be you're just running out of memory and some kind of sleep statement would help.&lt;BR /&gt;
&lt;BR /&gt;
Not that I really understand what you're doing but may be another approach could be to wrap all your code into a macro and then loop over this macro (just having as first node a "%macro" statement and as last node a "%mend" and then a loop calling the macro and passing the parameter values.&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
    <pubDate>Thu, 16 Jun 2011 11:26:14 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2011-06-16T11:26:14Z</dc:date>
    <item>
      <title>Macro/vbscript breaking down?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Macro-vbscript-breaking-down/m-p/12941#M2826</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am using the EG 4.3 ,where I have a certain project set up. Inside the project there are 3 simple macros (for interchanging some filters based on a name from a list) as well as approx 200 other query buiders, simple run and extraction programs etc. Now, I need to run this project 70 times based on those different names from the list, therefore I have found the program in VBS that I have been using.&lt;BR /&gt;
&lt;BR /&gt;
Now, this all runs smoothly, however the problem I have is that it keeps on 'crashing' (i.e. stops processing) in random places at random times. Sometimes it does 20 items from the list (i.e. runs the project 20 times) and then stops, other times it just runs 2 times and stops. I have tried to split the project into 2 smaller ones (thinking that this could be due the the amount of queries), but the problem still prevails.&lt;BR /&gt;
&lt;BR /&gt;
On the other hand I have identical VBS attached to different project (it's kind of a prestage to this one above), which has identical macros, but has only about 10 queries and this one runs smoothly (i.e. does it 70 times without interuption).&lt;BR /&gt;
&lt;BR /&gt;
Does anyone know what could cause these interuptions and how to rectify this?&lt;BR /&gt;
&lt;BR /&gt;
Many thanks in advance,&lt;BR /&gt;
&lt;BR /&gt;
Simi&lt;BR /&gt;
&lt;BR /&gt;
P.S.: the VBS code is as follows:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Dim app&lt;BR /&gt;
Call dowork&lt;BR /&gt;
&lt;BR /&gt;
If not (app Is Nothing) Then&lt;BR /&gt;
    app.Quit&lt;BR /&gt;
    Set app = Nothing&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sub dowork()&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Dim prjName&lt;BR /&gt;
    Dim prjObject&lt;BR /&gt;
    Dim dc		&lt;BR /&gt;
    Dim d				&lt;BR /&gt;
    Dim tc				 &lt;BR /&gt;
    Dim t				 &lt;BR /&gt;
    Dim rc				&lt;BR /&gt;
    Dim r                      &lt;BR /&gt;
    Dim outfile			&lt;BR /&gt;
    Dim fileSys               &lt;BR /&gt;
    Dim Contents               &lt;BR /&gt;
    Dim ext                    &lt;BR /&gt;
    &lt;BR /&gt;
    outfile = ""  'Output file name&lt;BR /&gt;
&lt;BR /&gt;
    Set fileSys = CreateObject("Scripting.FileSystemObject")&lt;BR /&gt;
    Set Contents = fileSys.OpenTextFile(outfile, 2, True)&lt;BR /&gt;
&lt;BR /&gt;
    'Name the project to run&lt;BR /&gt;
    prjName = ""    'Project Name&lt;BR /&gt;
      &lt;BR /&gt;
    Set app = CreateObject("SASEGObjectModel.Application.4.3")&lt;BR /&gt;
    If Checkerror("CreateObject") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
    Set prjObject = app.Open(prjName,"")&lt;BR /&gt;
    If Checkerror("app.Open") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
  	d = 0&lt;BR /&gt;
	do while d &amp;lt; 75&lt;BR /&gt;
	&lt;BR /&gt;
    prjObject.run&lt;BR /&gt;
    If Checkerror("Project.run") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
	&lt;BR /&gt;
	d = d + 1&lt;BR /&gt;
	Loop&lt;BR /&gt;
           &lt;BR /&gt;
       prjObject.Close&lt;BR /&gt;
    If Checkerror("Project.Close") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
       &lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function Checkerror(fnName)&lt;BR /&gt;
    Checkerror = False&lt;BR /&gt;
    &lt;BR /&gt;
    Dim strmsg&lt;BR /&gt;
    Dim errNum&lt;BR /&gt;
    &lt;BR /&gt;
    If Err.Number &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
        strmsg = "Error #" &amp;amp; Hex(Err.Number) &amp;amp; vbCrLf &amp;amp; "In Function " &amp;amp; fnName &amp;amp; vbCrLf &amp;amp; Err.Description&lt;BR /&gt;
        'MsgBox strmsg  &lt;BR /&gt;
        Checkerror = True&lt;BR /&gt;
    End If&lt;BR /&gt;
         &lt;BR /&gt;
End Function&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 14 Jun 2011 12:59:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Macro-vbscript-breaking-down/m-p/12941#M2826</guid>
      <dc:creator>Simi</dc:creator>
      <dc:date>2011-06-14T12:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/vbscript breaking down?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Macro-vbscript-breaking-down/m-p/12942#M2827</link>
      <description>Hi &lt;BR /&gt;
&lt;BR /&gt;
My VBS knowledge is rather basic but if I get this right then you're starting 70 EG sessions more or less in parallel. &lt;BR /&gt;
May be you're just running out of memory and some kind of sleep statement would help.&lt;BR /&gt;
&lt;BR /&gt;
Not that I really understand what you're doing but may be another approach could be to wrap all your code into a macro and then loop over this macro (just having as first node a "%macro" statement and as last node a "%mend" and then a loop calling the macro and passing the parameter values.&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Thu, 16 Jun 2011 11:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Macro-vbscript-breaking-down/m-p/12942#M2827</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2011-06-16T11:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/vbscript breaking down?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Macro-vbscript-breaking-down/m-p/12943#M2828</link>
      <description>Hi Patrick,&lt;BR /&gt;
&lt;BR /&gt;
Technically speaking, I am not running them in parallel, but they are executed one after another from my index list. Unfortunately, I am not very familiar with SAS macros, hence bit of a no go for me.&lt;BR /&gt;
&lt;BR /&gt;
Back to the problem, I may have found a source of my problems. Today, when running a single iteration (as opposed to the whole list), my project designer got stuck on 1 (completely random) query, saying that it was collecting data. Normally, it is only matter of seconds for this particular query, however after 5 minutes EG was still showing 'collecting' without any error messages displayed. I started to check the previous datasets linked to this query, when I got to the very last one preceding this query. &lt;BR /&gt;
&lt;BR /&gt;
Upon opening I received the following error message: "SAS Enterprice Guide cannot open the data file:"NAME OF THE FILE". Error HRESULT E_Fail has been returned from a call to a COM component".&lt;BR /&gt;
&lt;BR /&gt;
I was quite surprised that upon failing to open this dataset the EG was still trying to run the query without breaking down (stricktly speaking it had no dataset to run the query for!). And this is exactly the situation, when I run it for the whole list. At some point CPU usage for both tasks drops to 0%, whilst still using the system memory and no error messages show up.&lt;BR /&gt;
&lt;BR /&gt;
Has anyone encountered similar problem or anyone has suggestion on this?&lt;BR /&gt;
&lt;BR /&gt;
Thank you,&lt;BR /&gt;
&lt;BR /&gt;
Simi</description>
      <pubDate>Thu, 23 Jun 2011 08:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Macro-vbscript-breaking-down/m-p/12943#M2828</guid>
      <dc:creator>Simi</dc:creator>
      <dc:date>2011-06-23T08:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/vbscript breaking down?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Macro-vbscript-breaking-down/m-p/12944#M2829</link>
      <description>Hi Simi&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your patience with my ignorance.&lt;BR /&gt;
&lt;BR /&gt;
What you describe starts to feel like a question for SAS Tech Support.&lt;BR /&gt;
&lt;BR /&gt;
Below some code to illustrate the macro approach:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/* first node */&lt;BR /&gt;
%macro loop(parameter);&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/* all the nodes in between */&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  put / 80*'*';&lt;BR /&gt;
  put "Value of parameter is: &amp;amp;parameter";&lt;BR /&gt;
  put 80*'*' /;&lt;BR /&gt;
run;&lt;BR /&gt;
/* ********* */&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/* last node */&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
data YourList;&lt;BR /&gt;
  var='This Value 1'; output;&lt;BR /&gt;
  var='This Value 2'; output;&lt;BR /&gt;
  var='This Value 3'; output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  set YourList;&lt;BR /&gt;
  call execute ('%loop('||var||')') ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Thu, 23 Jun 2011 09:38:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Macro-vbscript-breaking-down/m-p/12944#M2829</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2011-06-23T09:38:23Z</dc:date>
    </item>
  </channel>
</rss>

