/*** TIP 00377 ***/

I want to capture from the user a 4-digit year value via a desktop icon.
The year value becomes part of a path value in a SAS process opened via
the same icon.  Presumably, the user could type the year value or select it
from a list of year values.

Any suggestions as to how to accomplish this?

Solution #1 Author: Mark Terjeson Email: mark.terjeson@nwcsr.com %window GET_YEAR rows=9 columns=35 irow=1 icolumn=2 color=black #2 @8 'Enter the year:' color=gray @24 theYear 4 required=yes attr=underline color=yellow ; %display GET_YEAR; %put NOTE: The year ready for use is &theYear; libname mylib "c:\foobar\blah\&theYear\mystuff"; data mylib.mydata; set blah... run;
Solution #2 Author: Arto Raiskio Email: arto.raiskio@SUOMENPOSTI.COM vbs sample below, this runs a short file called c:\windows\thedate.vbs (save the code via notepad into this file) and writes output to g:\tmp\thedate.txt (change to suit your needs), ie. today as 21.07.2003 option explicit dim today dim outputstring dim logfile dim fso dim fsout logfile = "g:\tmp\thedate.txt" const forreading = 1 const forwriting = 2 const forappending = 3 set fso = createobject("Scripting.FileSystemObject") set fsout = fso.OpenTextFile(logfile,ForWriting,True) outputstring = date fsout.WriteLine outputstring fsout.Close WScript.Quit 0
Solution #3 Author: Nathaniel Wooding Email: Nathaniel_Wooding@dom.com *the following code, when invoked, opens a data step data entry window and asks the user for a date and time that were recorded improperly by a data logger as well as the correct date and time. When the user closes the window, the time interval needed to adjust the incorrect date is calculated and returned in the window. ************************************; DATA _NULL_; WINDOW D1 COLOR = RED IROW =1 ICOLUMN = 5 ROWS=15 COLUMNS= 60 #3 @39 D1 YYMMDD6. #5 @39 TIME1 #7 @39 D2 YYMMDD6. #9 @39 TIME2 REQUIRED = YES PROTECT=NO DISPLAY = YES #1 @2 'DATE TIME CORRECTION FACTOR INPUT' #3 @2 'ENTER THE INCORRECT DATE (YYMMDD): ' #5 @2 'ENTER THE INCORRECT TIME ( HH ): ' #7 @2 'ENTER THE CORRECT DATE (YYMMDD): ' #9 @2 'ENTER THE CORRECT TIME ( HH ): ' ; DISPLAY D1 ; V1=COMPRESS(PUT( D1,DATE7.)]]':']] TIME1]]':00') ; S1=INPUT(V1,DATETIME.); SD1=S1; V2=COMPRESS(PUT( D2,DATE7.)]]':']] TIME2]]':00') ; S2=INPUT(V2,DATETIME.); DIF=S2-S1; DIFS=INTCK('HOUR',S1,S2); WINDOW D2 COLOR =CYAN IROW =16 ICOLUMN = 5 ROWS=10 COLUMNS= 60 #14 @35 DIFS REQUIRED = YES PROTECT=NO DISPLAY = YES #14 @2 'THE INTERVAL TO BE ADDED IS '; OUTPUT; DISPLAY D2 ; STOP; RUN; A little comment on what is happening with regarding this particular set of code. As you will see, it may be somewhat useful from the standpoint of the original application or as a means of finding the seconds interval between two date-time variables. In our particular case, we had some aging dataloggers whose on-board clock batteries were dieing and, when they did so, reverted to the earliest date that the clock chip could handle. The data were good but I needed to adjust the date/time stamp of each hour's observation. I used the code in a mainframe clist in order to calculate the time correction and then added this to my update program. Nat
You can write a VB Script that axes the user for the year and then start SAS using the SYSPARM option (it will create a macro variable SYSPARM containing the year: varInput = 0 Set WshShell = CreateObject("WScript.Shell") varInput = InputBox("please type a year") WshShell.Run ("sas -sysparm '" & varInput & "'") This will start SAS in interactive mode, but it is possible to run a SAS program completely invissible in batch mode. For example you could make the script run a SAS program that creates a HTML report based on the value the user types. The only thing the user will see is the report. Actually, it is possible to run processes on other machines as well - check out the script "ReRun.vbs", Written by Martin Krolik (martin@krolikconsulting.com). This means that the user does not need SAS at all! Hope this helps (and thanks for thinking the possibility!) Stig Eide stigeide@YAHOO.COM
From Michael Bramley - You could use the Window (macro or base) routine to define a dialogue box/window to prompt for and obtain the year. data _null_; window getyear #9 @26 'WELCOME TO JULES'' SYSTEM' color=black #12 @19 'PLEASE ENTER THE YEAR ' YearVal #14 @27 'Press ENTER to continue'; display getyear; call symput( 'yearval', put(yearval,z4.)); stop; run; %put &yearval;
Lex Jansen's SUGI Papers on WINDOW/%WINDOW Finally, last evening I went to Lex Jansen's SUGI papers website http://www.lexjansen.com/sugi/ where I found the following SUGI papers/posters about WINDOW/%WINDOW. These items came up, among others, with a search on %WINDOW. 21-28 192-27 22-25 76-25 92
/*** end of tip 00377 ***/