BookmarkSubscribeRSS Feed
elwayfan446
Barite | Level 11

I want to ask a follow up question to @CaseySmith to this thread from 2016 but it is locked.  In your solution to export logs from the VB Script, it currently exports logs from each process flow in the project.  How can I change this so it is only exporting the log from a specific containername?

 

https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-SAS-log-to-external-files/td-p/287838

 

Thanks for your help!

4 REPLIES 4
CaseySmith
SAS Employee

Hi @elwayfan446,

 

Rather than iterating the project's CodeCollection (which contains all the code nodes in the project), I would get the desired process flow (I indexed it by name in the example below), then iterate its Items collection.  For example:

 

    '-----
    ' export the log for each program in a specific process flow
    '-----
    const SASEGItemType_egCode = 1
    Dim item
    Set containerObject = prjObject.ContainerCollection.Item("Process Flow 2")
    For Each item in containerObject.Items
        If item.Type = SASEGItemType_egCode Then
            'MsgBox item.Log.Text
            item.Log.SaveAs "c:\temp\" & item.Name & ".log"
        End If
    Next

 

Since a process flow's Items collection can contain more than just code/programs, I checked the type in the example above to only export the logs for programs.  You'll have to adjust if you want to export the log for other runnable types (ex. tasks, query builders, stored processes).

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

elwayfan446
Barite | Level 11
Thanks for following up, Casey! Can you tell me which lines of code I would change to include the other runnable types? I am looking for errors anywhere in the process flow. It looks like the SASEGItemType_egCode but I am not sure what the other codes would be.



Thanks!


CaseySmith
SAS Employee

Sure, no problem @elwayfan446.  Here is the SASEGItemType enumeration defined in SASEGScripting.dll:

 

public enum SASEGItemType
{
	egLog = 0,
	egCode = 1,
	egData = 2,
	egQuery = 3,
	egContainer = 4,
	egDocBuilder = 5,
	egNote = 6,
	egResult = 7,
	egTask = 8,
	egTaskCode = 9,
	egProjectParameter = 10,
	egOutputData = 11,
	egStoredProcess = 12,
	egStoredProcessParameter = 13,
	egPublishAction = 14,
	egCube = 0xF,
	egReport = 18,
	egReportSnapshot = 19,
	egOrderedList = 20,
	egSchedule = 21,
	egLink = 22,
	egFile = 23,
	egIntrNetApp = 24,
	egInformationMap = 25,
	egProjectLog = 26
}

And here are the types that explicitly expose a Log property:

 

Task
Query
StoredProcess
Code
PublishAction

 

And the Log type exposes a Text property.

 

So, your updated code might look something like this:

 

    '-----
    ' export the log for each runnable item in a specific process flow
    '-----
    const SASEGItemType_egLog = 0
    const SASEGItemType_egCode = 1
    const SASEGItemType_egQuery = 3
    const SASEGItemType_egTask = 8
    const SASEGItemType_egStoredProcess = 12
    const SASEGItemType_egPublishAction = 14
    Dim item
    Set containerObject = prjObject.ContainerCollection.Item("Process Flow 2")
    For Each item in containerObject.Items
        If item.Type = SASEGItemType_egCode Or _
            item.Type = SASEGItemType_egQuery Or _
            item.Type = SASEGItemType_egTask Or _
            item.Type = SASEGItemType_egStoredProcess Or _
            item.Type = SASEGItemType_egPublishAction Then
            'MsgBox item.Log.Text
            item.Log.SaveAs "c:\temp\" & item.Name & ".log"
        ElseIf item.Type = SASEGItemType_egLog Then
            'MsgBox item.Text
            item.SaveAs "c:\temp\" & item.Name & ".log"
        End If
    Next

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

elwayfan446
Barite | Level 11
Casey, thanks so much for the information. As soon as I can get back on this, I will test it out and let you know. I really appreciate it.


hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1622 views
  • 2 likes
  • 2 in conversation