BookmarkSubscribeRSS Feed
Fluorite | Level 6

Hi all,


I'm in an environment running SAS EG 7.15 and working with a project that non-coders run on a semi-regular basis.


The project has several date-based macro variables stored in prompts. At present, if a date value is changed in the user prompt that comes up and the project is subsequently saved, the date reverts to it's old value upon re-opening the project. Is there a way within EG to have the 'default' value for each prompt be set to the last entered value? The only behaviour I seem to be able to get out of the prompt manager is either a fixed default value (which is a bit of a pain to update -- an most importantly is not able to be updated via the user prompt screen) or a missing value if no default is specified.


I'm very tempted to change to code-based assignment of these macro variables, so at least when the date is updated and project saved, the up-to-date date reference is also saved...




Meteorite | Level 14

I'm not aware of a way to directly update the value within Enterprise Guide of a Prompt such that it is saved and is the default for the next run.  Enterprise Guide projects are, under the covers, zip files.  If you want to get fancy, you could rename the .egp file to .zip, find the spot where the Prompt default values are serialized, update the values, save the file, and rename it back to .egp, but that sounds like a bit of work, and you could possibly render the project unreadable.  It can be done (I think), but make a backup of your .egp file before you start experimenting.





Meteorite | Level 14

OK, I can see the outlines of what would need to be done.  After you name your EG project file from .egp to .zip, inside the zip archive will be a file called project.xml.


Edit the xml in a note pad (eventually you'd want to do this programmatically).


Look for the Parameters section.  I can see in my Parameters section, the prompt I created, Test_Prompt.  Nearby is a value specification.  One would change the value to whatever the updated value is and save the file.  In the below example, the value is "ABC-XYZ".

<PWParameter>&lt;PromptGroup obj="p1" version="1.0"&gt;&lt;DefinitionsAndSubgroups&gt;&lt;TextDefinition obj="p2" 
promptId="PromptDef_1627003124217_818636" name="Test_Prompt" macroVarOutputLevel="2" minValueCount="0" macroVarListDelimiter=","
macroVarListQuote="&amp;quot;"&gt;&lt;Label&gt;&lt;Text obj="p3" xml:lang="en-US"&gt;Test_Prompt&lt;/Text&gt;&lt;/Label&gt;&lt;DefaultValue&gt;&lt;String obj="p4"
value="ABC-XYZ"&gt;&lt;/String&gt;&lt;/DefaultValue&gt;&lt;UserInfo&gt;&lt;MapText obj="p5"
key="EGkeepValues"&gt;true&lt;/MapText&gt;&lt;/UserInfo&gt;&lt;/TextDefinition&gt;&lt;/DefinitionsAndSubgroups&gt;&lt;/PromptGroup&gt;</PWParameter> </ParameterCollection> </Parameters>


Fluorite | Level 6

Very interesting. I wasn't aware a project could be 'read' in that manner. I think I've tried to load an *.egp file into a text editor before, which of course doesn't yield anything of use... It'll certainly be useful to try to extract code, should a project corrupt - which hasn't happened to me for a while, but still.


You've certainly piqued my curiosity. I can see a couple of placed where the macro values I'm looking at are stored - once as the 'default value', I believe and again where it appears in a stored list for the same parameter variable. Any attempt to modify the xml and re-attach it to the project, or unzip and rezip the whole thing, however, seems to fail - that failure could be related to path length as much as anything else, now that I think about it.


I think as far as a working solution, it's not what I'm looking for anyway, as I'd like to still have everything 'contained' within the project. For now I have changed the macro assignment to be code based which, of course, means any updated values are saved along with the project.


A very interesting tid-bid, though, and I'll definitely keep it in the back of my mind!

Meteorite | Level 14

This is definitely not a straight-forward solution!  But I'm pretty sure that it can be "contained" within an EG project.


By the way, yesterday, I was able to successfully modify an EG project such that the default macro variable values displayed in the EG prompt were in fact updated.  So, it can work.


If you wanted to contain such a process within an EG project, you would do something along the lines of the following:

1)  Run the project. At end of run, write to a SAS dataset (or text file or something), saving the values of the salient macro vars.

2)  Write a .bat, .ps1, or similar script to launch the EG project rather than having the user launch it directly via Windows.  As part of the script, perform some Windows functions and launch a batch SAS job (pretty easy to code; I can give you examples if you haven't done this before).

3)  The script would:  

    A)  Back up the .egp file

    B)  Rename the .egp file to .zip

    C)  Launch a SAS batch job to read the .zip file, looking for the project.xml file within.  @ChrisHemedinger has some examples on his SAS Dummy blog of using SAS to directly read zipped files as I recall.

    D)  Update the project.xml file with the values saved in Step 1.

    E)  Re-write the .zip file (or write a new zip file).

    F)  Do such renames as are required to get either the re-written .zip file or the new .zip file renamed to the original .egp file name

    G)  Open the .egp file 


Obviously, this is pretty complicated, but if the user community were particularly insistent, it could be done.  It is not without peril, which is why I would include a backup step as the first action in the script that launches Enterprise Guide.



Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1 like
  • 2 in conversation