BookmarkSubscribeRSS Feed
ayin
Quartz | Level 8

What I have:

First of all, users have defined a global macro variable:

%let class = A B;

What I want:

For each of the word in the 'class' macro variable (in this case, they would be 'A' and 'B'),

I want to create a new global macro variable named '.._Index' (e.g. 'A_Index') and give it a value, using Prompt Manager.

 

Originally using the following codes could achieve what I want:

%let A_Index = 5;

 And if it's in prompt manager, the pop-out window, which asks user to put in value, would look like:

Screenshot - Prompt Manager3(figure 1.1)

 

The problem is, if the global macro variable 'class' has different values, e.g.

%let class = C D; /* compared to 'A B' mentioned above */

Then we'll need to make manual changes in the Prompt Manager: create C_Index, D_Index; and then add them to the program/process - properties - prompt, remove A_Index, B_Index from there.

 

The question is, Is there a way to let SAS EG automatically make changes above and to the pop-out window (figure 1.1)?

 

 

maybe writing SAS codes instead of using Prompt Manager to generate that window.

9 REPLIES 9
Reeza
Super User

I don't think you can do it automatically but you can recalculate what you need using a data step. 

You've posted this twice and I still don't have a clear idea of what you want. 

Post what you have - exactly what the Prompt Manager creates versus what your process wants. Honestly at this point it's easiest to reprocess the values to your old system than refactor your code. At some point you may want to though. 

ayin
Quartz | Level 8
Thanks Reeza. The post has been updated, hopefully able to clarify the problem.
rogerjdeangelis
Barite | Level 11
Using a data entry window to get family names into global macro variables

see (link to this message)
https://goo.gl/jCzm8P
https://communities.sas.com/t5/SAS-Enterprise-Guide/Prompt-Manager-dynamic-input-list/m-p/346552

HAVE
====

  Macro variable class

    %let class=MOM DAD CHILD1 CHILD2 CHILD3;

WANT (Global Macro Variables using pop up data entry)

+---+------------------------------+
|COMMAND ===>                      |
+---+------------------------------+
|                                  |
| MOM_index     __LIZ <ENTER>      |
|                                  |
| DAD_index     __ED  <ENTER>      |
|                                  |
| CHILD1_index  __TAD <ENTER>      |
|                                  |
| CHILD2_index  __TIM <ENTER>      |
|                                  |
| CHILD3_index  __TED <ENTER>      |
|                                  |
+----------------------------------+

 Global macro variables

    MOM_index    = LIZ
    DAD_index    = ED
 CHILD1_index    = TAD
 CHILD2_index    = TIM
 CHILD3_index    = TED

WORKING CODE
===========

     window chose irow=5 rows=25
     #5 @12 "   MOM_Index"     MOM_Index $3. attr=underline
     #6 @12 "   DAD_Index"     DAD_Index $3. attr=underline
     #7 @12 "CHILD1_Index"  CHILD1_Index $3. attr=underline
     #8 @12 "CHILD2_Index"  CHILD2_Index $3. attr=underline
     #9 @12 "CHILD3_Index"  CHILD3_Index $3. attr=underline
     display chose;

FULL SOLUTION
=============

*_  __
(_)/ _|      _ __ ___ _ __ _   _ _ __
| | |_ _____| '__/ _ \ '__| | | | '_ \
| |  _|_____| | |  __/ |  | |_| | | | |
|_|_|       |_|  \___|_|   \__,_|_| |_|

;

%symdel
     CLASS
     A_INDEX
     B_INDEX
     C_INDEX
     D_INDEX
     E_INDEX
 / nowarn;

proc datasets lib=work;
delete want;
run;quit;

%let class=MOM DAD CHILD1 CHILD2 CHILD3;


%let clscnt=%sysfunc(countw(&class));
%put &=clscnt;

* CLSCNT=5;

%let class="%sysfunc(tranwrd(&class,%str( ),%str("," )))";
%put &=class;

* CLASS="MOM"," DAD"," CHILD1"," CHILD2"," CHILD3";
*          _       _   _
 ___  ___ | |_   _| |_(_) ___  _ __
/ __|/ _ \| | | | | __| |/ _ \| '_ \
\__ \ (_) | | |_| | |_| | (_) | | | |
|___/\___/|_|\__,_|\__|_|\___/|_| |_|

;

data _null_;
  retain cho "window chose irow=5 rows=25";
  length lyns $5000;
  array classes[&clscnt.] $32 (&class.);
  do i=1 to dim(classes);
     lyns=catx(' ',lyns,cats('#', put(i+4,3.)), '@12 "',cats(classes[i],'_Index'),
     '"',cats(classes[i],'_Index'),'$3. attr=underline');
  end;
  lyns=catx(' ',cho,lyns,';display chose;');
  call symputx('lyns',lyns);
  rc=dosubl('
     data WANT;
        &lyns;
        output;
        array chr _character_;
        do over chr;
           call symputx(vname(chr),chr,"G");
        end;
        stop;
     run;quit;

  ');
run;quit;

%put &=MOM_index     ;
%put &=DAD_index     ;
%put &=CHILD1_index  ;
%put &=CHILD2_index  ;
%put &=CHILD3_index  ;


MOM_index    = LIZ
DAD_index    = ED
CHILD1_index = TAD
CHILD2_index = TIM
CHILD3_index = TED




Reeza
Super User

Maybe look into cascading prompts?

ayin
Quartz | Level 8

Hi @rogerjdeangelis,

Your codes look promising. After I run it:

%let class = MOM DAD CHILD1 CHILD2 CHILD3;

%let clscnt=%sysfunc(countw(&class));
%put &=clscnt;
%let class="%sysfunc(tranwrd(&class,%str( ),%str("," )))";
%put &=class;

data _null_;
  retain cho "window chose irow=5 rows=25";
  length lyns $5000;
  array classes[&clscnt.] $32 (&class.);
  do i=1 to dim(classes);
     lyns=catx(' ',lyns,cats('#', put(i+4,3.)), '@12 "',cats(classes[i],'_Index'),
     '"',cats(classes[i],'_Index'),'$3. attr=underline');
  end;
  lyns=catx(' ',cho,lyns,';display chose;');
  call symputx('lyns',lyns);
  rc=dosubl('
     data WANT;
        &lyns;
        output;
        array chr _character_;
        do over chr;
           call symputx(vname(chr),chr,"G");
        end;
        stop;
     run;quit;

  ');
run;quit;

%put &=MOM_index     ;
%put &=DAD_index     ;
%put &=CHILD1_index  ;
%put &=CHILD2_index  ;
%put &=CHILD3_index  ;

There is an error in the Log and we couldn't get any result:

ERROR: The DATA STEP windowing environment cannot be initialized due to a XU supervisor failure.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WANT may be incomplete.  When this step was stopped there were 0 observations and 5 variables.

A bit research shows that it might be due to the difference between base SAS and SAS EG? We only have SAS Enterprise Guide 7.1 (64-bit).

How should we resolve it?

Patrick
Opal | Level 21

@ayin

he DATA STEP windowing environment cannot be initialized due to a XU supervisor failure.

 

The SAS windowing environment is only available for "PC SAS". That's the old fashioned GUI which sits directly on top of a SAS server (=all the binaries installed locally on your machine). Some people will now "hit me" but: That's an outdated architecture.

 

You can't use the windowing environment in any client/server architecture (EG, AMO, SAS Studio,.....long long list).

rogerjdeangelis
Barite | Level 11
You need to contact your IT dept and tell them you need full legacy SAS.

Just send the log with the error.
Patrick
Opal | Level 21

@ayin

I believe if you could describe the process you want to implement and where you want to have user interactions (prompts), would help us to understand and give you better advice.

 

What's not clear to me: Where does the first global macro variable come from? Is that already user input via a prompt?

 

Have you already investigated what cascading and dynamic (data driven) prompts could do for you?

 

ayin
Quartz | Level 8

@Patrick

The user interactions happen when users are asked to put in value for 'A_Index' and 'B_Index': originally achieved by changing the codes in a script: 

%let A_Index = 5;

but now we would like to use prompts.

 

As for the first global macro variable 'class', its value can either be generated from a preceding process, please see

another SAS communities post (can be already user input via a prompt)

Or be re-defined by users using codes: 

%let class = C D;

This is not part of concerns.

 

I'm investigating cascading and dynamic (data driven) prompts but currently find difficulties implementing that concept to this case.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 9 replies
  • 2135 views
  • 1 like
  • 4 in conversation