BookmarkSubscribeRSS Feed
mcypert16
Calcite | Level 5

Hi,

 

I am writing a SAS application in SCL that takes random samples of a uniform distriubtion (using macros) to show that as the sample size increases, the sampling distribution of the mean takes on a more normal shape (I plan on doing it for multiple distributions, once I figure out the Uniform first).  My program works like this at the moment:  the user selects a distribution and then the %macro uniform and %macro usd are both compiled and executed.  Then the proc univariate displays the moments of the sample distribution.  In the picture of my frame, you can ignore the number of sample(s) and size of sample(s), textlabels and textentry boxes because I have not gotten to that step in my program yet.    

 

I have searched the web for a long time now and can't really find many examples creating applications using SCL.  My code is kind of long, so if any one can help I would appreciate it.   

 

My goal is to get:  proc sgplot and proc univariate html ouput into the component windows, but I have only been able to get listing output in my external file viewer control (I might need to try a different component, such as graph output control).  Any help would be nice.  Thanks.

 

 

  Frame_and_output.PNG

 

dcl num rc;                                                                                                                             
                                                                                                                                        
dcl list messageList = {};                                                                                                              
                                                                                                                                        
dcl char(10) distribution,                                                                                                              
    char(2) command;                                                                                                                    
                                                                                                                                        
Init:                                                                                                                                   
                                                                                                                                        
      rc = insertc(messageList, 'To create the report, please select a distribution');                                                  
                                                                                                                                        
      rc = filename('out', ' ', 'temp');                                                                                                
                                                                                                                                        
      ReportViewer._showEndOfFile('no');                                                                                                
                                                                                                                                        
return;                                                                                                                                 
                                                                                                                                        
CreateRptButton:                                                                                                                        
                                                                                                                                        
      if ReportViewer.fileref ne ' ' then ReportViewer.fileref = ' ';                                                                   
                                                                                                                                        
      distribution = distComboBox.selectedItem;                                                                                         
                                                                                                                                        
      if distribution ne ' ' then do;                                                                                                   
                                                                                                                                        
         submit continue;                                                                                                               
                                                                                                                                        
         proc printto print=out new;                                                                                                    
                                                                                                                                        
         ods noproctitle;                                                                                                               
                                                                                                                                        
         options nodate nonumber nocenter;                                                                                              
                                                                                                                                        
         %macro Uniform;                                                                                                                
         %local i k;                                                                                                                    
         data work.uniform;                                                                                                             
            call streaminit(1234);                                                                                                      
               %do i=1 %to 10;                                                                                                          
                  %do k=1 %to 10;                                                                                                       
                     Sample&k=10*rand("Uniform");                                                                                       
                  %end;                                                                                                                 
                  output;                                                                                                               
               %end;                                                                                                                    
         run;                                                                                                                           
         %mend Uniform;                                                                                                                 
                                                                                                                                        
         %Uniform                                                                                                                       
                                                                                                                                        
         proc transpose data=work.uniform out=work.uniform1 name=sample;                                                                
         run;                                                                                                                           
                                                                                                                                        
         %macro usd;                                                                                                                    
         %local i;                                                                                                                      
         data work.usd(drop=col1-col10);                                                                                                
            set work.uniform1;                                                                                                          
               %do i=1 %to 10;                                                                                                          
                  sample_mean=mean(of col1-col10);                                                                                      
               %end;                                                                                                                    
         run;                                                                                                                           
         %mend usd;                                                                                                                     
                                                                                                                                        
         %usd                                                                                                                           
                                                                                                                                        
         ods select moments;                                                                                                            
         proc univariate data= work.usd;                                                                                                
            var sample_mean;                                                                                                            
         run;                                                                                                                           
                                                                                                                                        
         proc printto;                                                                                                                  
         run;                                                                                                                           
                                                                                                                                        
         options date number center;                                                                                                    
         endsubmit;                                                                                                                     
                                                                                                                                        
         ReportViewer.fileref='out';                                                                                                    
         end;                                                                                                                           
                                                                                                                                        
         else command = messagebox(messageList, '!', 'O', 'Application warning message');                                               
return;                                                                                                                                 
                                                                                                                                        
Term:                                                                                                                                   
      messageList = dellist(messageList);                                                                                               
                                                                                                                                        
      reportViewer.fileref = ' ';                                                                                                       
                                                                                                                                        
      rc = filename('out', ' ');                                                                                                        
return;

 

    

 

 

 

 

  

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

Sorry, I can't really help you, last time I used AF/SCL was back in 2000!  I wouldn't recommend using it.  SAS has the ability to interact with the big languages of the time:

Java:

https://support.sas.com/resources/thirdpartysupport/v93/jres.html

.Net:

http://support.sas.com/rnd/itech/doc9/dev_guide/dist-obj/winclnt/windotnet.html

 

Not to mention R, Python, VB etc. or in fact anything you can call from the command line or via process.  

 

There are alos other simpler things you could try, for instance, you have two boxes for paramters, just pop them in a program at the top as:
%let no_samples=;

%let size=;

Then have the proc sgplot and univariate use those macro parameters.  Thats the simplest way.

BrunoMueller
SAS Super FREQ

Hi

 

I agree with @RW9 I would no longer develop SCL based applications.

 

Here is a brief guide on how to use OLE objects within your frame entry, provided you run SAS on windows.

Please note this guide was created in 2002.

 

How to use the OLE Insert Class

The sashelp.classes.insert_c class is basically a dot notation style object of the SAS Version 6 "OLE - Insert Object". You can still use the SAS Version 6 one if you want, but then you won't be able to do simple dot notation with it.

The following steps outline how one can use any OLE object within a frame using the sashelp.classes.insert_c class:

 

  • Open/Create a new Frame entry
  • Either add the resource sashelp.fsp.experimentalafcomponents.resource, or
    add the class sashelp.classes.insert_c to your components window
  • Drag the OLE Insert Object class to your frame
  • A pop-up window will open, choose the Create Control radio button and then select the OLE object you want
  • A new object will be created in the frame that will surface the methods and properties of this OLE object.

Unfortunately since Windows 2000 the "Microsoft Web Browser" is not available anymore. There have been some discussions on how one can add it, so it will appear on the list. The following steps worked for me:

  • Add OLE Insert Object to a frame
  • When the Insert Object dialog comes up
  • Select Create Control
  • Use Add Control button
  • Choose c:\winnt\system32\mshtml.dll.

 

A test on my system that I can not find the above mentioned module, there are plenty of other for Excel, RTF or PDF etc.

 

Maybe this will help you.

 

Bruno

mcypert16
Calcite | Level 5

@RW9 thanks for the input.  My original sas macros do exactly what you said.  %uniform(Num=, Size=) and %usd(Num=&num, Size=&size), since it was executed in the %uniform(Num=, Size=) macro.  I thought it would be cool to try and write an application (in SAS) that lets the user select a distriubtion, number of samples, and size of samples that shows its sampling distribution about the mean.  I will look into Python.  I have used it before, but have not in a while, so I will have to learn the basic code again.

 

@BrunoMuellerthanks for the input.  I will look into the OLE insert class.     

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
  • 3 replies
  • 486 views
  • 0 likes
  • 3 in conversation