build sasuser.example.Create_report.frame
/* This is the frame SCL for the Create_report frame. */ /* */ /* The user selects a year, a quarter, and a country, */ /* and then clicks the CreateRptButton. Data that */ /* matches the user selections is pulled from */ /* SASHELP.PRDSALE, written to a file, and then */ /* displayed in the External File Viewer. */ dcl num rc; /* Numerical variable used as a return code. */ dcl list messageList={}; /* Creates an empty list. */ dcl char(7) countryName, char(1) quarterValue, char(4) yearValue, char(2) command; /* Declare character variables. */ INIT: /* Define a warning message. */ rc=insertc(messageList, 'To create the report, please ' || 'select values for year, quarter, and country.'); /* Assign a fileref to an external file. */ rc=filename('out', ' ', 'temp'); /* Turn off 'End of file' message. */ ReportViewer._showEndOfFile('no'); return; /* Executes when you click on the CreateRptButton */ CreateRptButton: /* If a fileref is already assigned to ReportViewer, clear the fileref. */ if ReportViewer.fileref ne ' ' then ReportViewer.fileref=' '; /* Initialize variables with user selections. */ countryName = CountryRadiobox.selectedItem; yearValue = YearCombobox.selectedItem; quarterValue = left(QuarterRadiobox.selectedItem); /* If all criteria have been selected, create a report . */ if countryName ne ' ' and yearValue ne ' ' and quarterValue ne ' ' then do; submit continue; /* Close the default ODS destination. */ ods html close; /* Enable the ODS listing destination. */ ods listing device=listing; /* Redirect SAS output to the temp file. */ proc printto print=out new; /* Suppress printing the PROC title. */ ods noproctitle; /* Set options to control procedure output. */ options nodate nonumber nocenter; /* Create a summary report of the PRDSALE table using */ /* selected values for Country, Year, and Quarter. */ proc means data = sashelp.prdsale nonobs sum; where country = '&countryName' and year = &yearValue and quarter = &quarterValue; class product; var predict actual; title1 'Sales Figures for &countryName: '; title2 'Quarter &quarterValue in &yearValue'; run; /* Redirect SAS output back to the default location. */ proc printto; run; /* Reset options that control procedure output. */ options date number center; endsubmit; ReportViewer.fileref = 'out'; end; /* If a criteria was not selected, display a warning dialog. */ else command = messagebox(messageList, '!', 'O', 'Application warning message'); return; TERM: /* Delete the SCL list. */ messageList=dellist(messageList); /* Clear the fileref assigned to ReportViewer. */ ReportViewer.fileref=' '; /* Clear the fileref OUT. */ rc=filename('out', ' '); return;