Pages

Sunday, August 4, 2013

Widgets

Create a progress bar in SAS

Progress bars are fairly easy to implement in SAS/AF however a little harder from base SAS. You can however produce progress bars for use in Data Steps or Macros. These are quite useful to let users know how a long macro is progressing, for instance. This example shows how to do so for a data step, though a similar technique can be used from macro language using the %WINDOW and %DISPLAY statements.

data _null_;
length pct $ 10 ruler progress $ 50 ;
left=byte(147) ;
right=byte(147) ;
ul=byte(149) ;
ur=byte(151) ;
ll=byte(155) ;
lr=byte(159) ;
ruler=repeat(byte(148),49) ;
bit=byte(164)||byte(164)||byte(164)||byte(164)||
byte(164) ;
window bar irow=5 rows=9 icolumn=15 columns=64
#1 @11 ul
@12 ruler
@62 ur
#2 @2 'Progress' color=orange
@11 left
@12 progress color=blue
@62 right
#3 @11 ll
@12 ruler
@62 lr
#4 @35 pct ;
progress=bit ;
pct=putn(.1,'percent.') ;
display bar noinput;
link pause ;
do i=1 to 9 ;
progress=repeat(bit,i) ;
pct=putn(.1+i*.1,'percent.') ;
display bar noinput;
link pause ;
end ;
stop;
return ;
pause:
now=time() ;
do while((now+1)>time()) ;
end ;
return ;
run;

No comments:

Post a Comment