BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sunny_nar2018
Obsidian | Level 7

Hello Team,

I am new to SAS and this is my first post. I have created a frame in SAS according to the 'Build the Display Data Frame' on pp.24 at the following URL: https://support.sas.com/documentation/cdl/en/afframe/65152/PDF/default/afframe.pdf

 

The frame has been built and it works but I cannot get it to filter the data using a pmenu I created. The frame with dialog box looks like the one below:

sas_displaywithdialogbox.PNG

 

You can notice the menubar on the top left hand side and when the user clicks on 'Options', the user should get the 'Filter Data' item, which will then open up a dialog box as shown above.

 

pmenu code

menu MenuSubset;

item 'Options' menu= opt;

menu opt;
item 'Filter Data' dialog=dialogmenu;

 

code in dialog box

 

dialog dialogmenu '%%wbuild(%1)';
     text #1 @20 'Data for Class - Analysis';
     text #2 @1 'Select a Gender:';
     radiobox default=1;
            rbutton #3 @5 'Male' substitute='Male';
            rbutton #4 @5 'Female' substitute='Female';
run;

 

the macro code, adapted from the SAS guide

 

%macro wbuild(gender);
/* check to see if value is present */
  %if &gender ne %then %do;
       where gender="&Gender";
  %end;

%mend wbuild;

 

The problem is that when I filter on 'Gender' nothing happens. I need to have a menu to interact with the data set and therefore using pmenu is essential. I would like to filter the data using a dialogbox with radio button. The data set is available within SAS (sashelp.class)

 

 

I would appreciate any help on this - please let me know if you have any question.

 

Thanks

Sunny

1 ACCEPTED SOLUTION

Accepted Solutions
sunny_nar2018
Obsidian | Level 7

Hi Ballardw,

 

I managed to resolve the issue which was linked to the WBUILD macro. 

 

%macro wbuild(sex);
       where sex="&Sex"; 

%mend wbuild;

 

For some reason, you have to click on the tableViewer in the frame for the filter (pmenu) to work. Once I did the above, I was able to select the M and F students from the Class dataset.

 

Thanks for your help / advice.

 

Kind Regards

Sunny

 

 

 

 

View solution in original post

9 REPLIES 9
ballardw
Super User

The picture of data seems to show values of gender as "F" or "M" (I say seems as there could be a display format changing a numeric 1/2 coded variable to M/F or similar). Your pmenu is returning values of "Male" and "Female". If this is the case then the PMENU isn't matching the values in the data because "F" is not equal to "Female".

 

And if the variable value is actually a numeric you want to match the numeric value not the displayed value.

sunny_nar2018
Obsidian | Level 7

Thank you Ballardw for your prompt reply. 

 

I have changed the code now to reflect your comments, but still it does not work.

 

proc pmenu catalog = libbrfss.BRFSSCAT;
  menu MenuSubsetTest;

  item 'Options' menu= opt;

  menu opt;
  item 'Filter Data' dialog=dialogmenu;

  dialog dialogmenu '%%wbuild(%1)';
        text #1 @20 'Class Dataset - Analysis';
        text #2 @1 'Select a Gender:';
        radiobox default=1;
               rbutton #3 @5 'Male' substitute='M';
               rbutton #4 @5 'Female' substitute='F';
  run;

 

%macro wbuild(sex);
/* check to see if value is present */
%if &sex ne %then %do;
       where sex="&Sex";
%end;

 

%mend wbuild;

 

Is there another macro I can use or an alternative way I can reach my objective?

 

Do you know of any example where a dialog box have been used to interact with data in a frame you could possible point me to? I already looked at the SAS guide at the following url http://documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=n0y5u96tv8kdrbn1ddtn7fxen...

 

Thanks

Sunny

ballardw
Super User

Did you look at :

http://documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=n1l5fdftjwyxaun1cqtn44br0...

 

on how to associate a pmenu with the frame? You have to provide the items in the frame to accept your selections and/or widgets to operate with them. I don't see any of that in your example so it is hard to provide more explicit comments.

Did the frame select the data set correctly?

Which widget are you using to call the pmenu? Store the result of the pmenu?

 

It has been a very long time since I worked with SAS/AF and really don't have the time to walk through each step of an AF or FSP program.

 

I would suggest following the examples in the documentation exactly. Including creating libraries and data sets as used in the examples before attempting with your own data.

 

sunny_nar2018
Obsidian | Level 7

Hello Ballardw,

Thanks for the link - I can confirm that the steps detailed in the document was followed exactly and the menubar appeared in the frame successfully. 

 

The problem I am having now is not with the frame but with the macro %%WBUILD, which does not seem to pick up the correct gender on filtering the data in the data frame.

 

If my understanding is correct, in the dialog box, the substitute statement corresponds to the value in the dataset for 'Sex' in the Class data set. So, when I select 'Female' in the dialog box for instance, the value 'F' is passed in the %%WBUILD(%1) macro. Now, when I define the %macro wbuild(sex), I passed 'sex' as the parameter thinking that it will therefore create a link with the dataset 'Class' from sashelp. but it does not. All I need is to be able to select 'F' and the dataset lists the data for Female students in the Class dataset.

 

At the moment, I am not sure whether I am using the correct macro and also if any additional statement is required for it to work correctly. I am mapping my code based on the link I previously shared.

 

I appreciate your help so far and if ever you need more information or code, please let me know.

 

Kind Regards,

 

 

ballardw
Super User

What code in the FRAME object did you set to subset the data?

 

You have to have something that actually uses the result of the pmenu.

sunny_nar2018
Obsidian | Level 7

Hello Ballardw,

 

Apologies for late reply. I don't have any code that I have added in the SCL program for the frame that links to the pmenu.

 

Is there an expectation to have a code in the SCL code editor?

 

Thanks

Sunny

ballardw
Super User

@sunny_nar2018 wrote:

Hello Ballardw,

 

Apologies for late reply. I don't have any code that I have added in the SCL program for the frame that links to the pmenu.

 

Is there an expectation to have a code in the SCL code editor?

 

Thanks

Sunny


There is an expectation that an action to be taken is indicated to the widget/frame or what have you to actually use a pmenu item.

 

Think a bit about what order things happen. Assume this is an FSEDIT window (just to have something to hang content on). So your AF program when activated brings the data from a dataset(supposedly set for the widget) into the window. Now to subset the data from what is currently displayed you select a menu item built with the pmenu. The widget displaying the selection from the pmenu has to be told what to do to only show the data you want. You might have pmenu that is intended to replace a specific value, set the window into data entry mode, change the column headers from variable name to variable label. So the result of the pmenu has to be linked to something that subsets the data. It might be SCL code, it might be SQL operating on the data set, it might be implementing a where in the FSEDIT.

 

As I said, it has been a very long time since I worked with AF and don't currently have anything that I could point to more specific examples other than the documentation.

 

Some quick google results that might apply

http://support.sas.com/kb/37/005.html

http://www2.sas.com/proceedings/sugi28/007-28.pdf

http://support.sas.com/documentation/cdl/en/afframe/65152/HTML/default/viewer.htm#n0wn0gehbjfo9xn1tu...

https://www.lexjansen.com/wuss/2001/WUSS01005.pdf

 

I do know that when I did work with SAS/AF I did not actually ever use PMENU as action buttons and selection lists seemed to work for what I needed.

sunny_nar2018
Obsidian | Level 7

Thank you Ballardw! I will look into the links you sent and if I have other questions or find a solution, I will update you.

 

Thanks

Sunny

sunny_nar2018
Obsidian | Level 7

Hi Ballardw,

 

I managed to resolve the issue which was linked to the WBUILD macro. 

 

%macro wbuild(sex);
       where sex="&Sex"; 

%mend wbuild;

 

For some reason, you have to click on the tableViewer in the frame for the filter (pmenu) to work. Once I did the above, I was able to select the M and F students from the Class dataset.

 

Thanks for your help / advice.

 

Kind Regards

Sunny

 

 

 

 

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1089 views
  • 1 like
  • 2 in conversation