/**********************************************************************/


%window welcome                                    
   group=short                                     
#1  @5 '** Income Tax Return for Single Filers  **'
#3  @5 '  With No Dependents  Form 1040EZ - 1990  '      
  group=long                                             
#1  @5 '** Income Tax Return for Single Filers  **'      
#3  @5 '  With No Dependents  Form 1040EZ - 1990  '      
#5  @2 ' 1) Enter INTEGER values.'                       
#7  @2 ' 2) Required information is displayed in red.'   
#9  @2 ' 3) For additional information you may reference'
#10 @2 '    the Form 1040EZ booklet.'                    
#12 @2 ' 4) Please hit ENTER to continue.';              


/**********************************************************************/


%display welcome.long;


/**********************************************************************/


%window name_add                                       
#3  @1  'Enter your name(first,initial,last)'          
#4  @1  '> ' name 55 a=underline required=yes c=red    
#6  @1  'Home address(number and street).    Apt. no.' 
#7  @1  '> ' add1 55 a=underline required=yes c=red    
#9  @1  'City,town or post office,state, and ZIP code' 
#10 @1  '> ' add2 55 a=underline required=yes c=red    
#12 @1  'Enter your social security number'            
#13 @1  '> ' ssn  9  a=underline required=yes c=red    
#15 @1  'Presidential Election Campaign  '             
#16 @1  'Do you want $1 to go to this fund?'           
    @38 'YES <' +1 pecy 1                              
    @47 '> NO <' +1 pecn 1                             
    @57 '>'  ;                                         
%window money                                          
  #5  @1  'Total wages,salaries, and tips. This should'
  #6  @1  'be shown in Box 10 of your W-2 form(s).'     
      @46 '$' +1 wages 9 a=underline required=yes c=red 
  #8  @1  'Enter your Federal income tax withheld from' 
  #9  @1  'Box 9 of your W-2 form(s)'                   
      @46 '$' +1 fitw 9 a=underline required=yes c=red  
  #11 @1  'Taxable interest income of $400 or less.'    
      @46 '$' +1 taxint 9 a=underline required=yes c=red
  #13 @1  'Can your parents(or someone else) claim you' 
  #14 @1  'on their return? '                           
      @38 'YES <' +1 incy 1 a=highlight c=red           
      @47 '> NO <' +1 incn 1 a=highlight c=yellow       
      @57 '>'  ;                                        

%let pecy=x;                                            
%display name_add;                                      


/**********************************************************************/


%let incy=X;   
%display money;


/**********************************************************************/


%window taxinter irow=16 icolumn=1 rows=8 columns=60    
#3  @2  'TRY AGAIN !' c=red a=blink                     
    @14 '- The amount of taxable interest          '    
#4  @2  'income you entered was greater than $400. '    
#5  @2  'You cannot use Form 1040EZ.               '    
#6  @2  'Type over the incorrect amount shown:     '    
    @47 '$' +1 taxint 9 a=underline required=yes c=red ;


/**********************************************************************/


%macro t1040ez(help=Y);

      /* initialize macro variables                   */     
   %let wages=;   %let taxinc=;   %let ssn=;     %let name=; 
   %let add1=;    %let add2=;     %let pecn=;    %let pecy=X;
   %let incy=X;   %let incn=;                                

      /* Determine if user requested help.            */     
   %if %upcase(&help)=Y %then %display welcome.long;         
      %else %display welcome.short;                          

      /* Prompt user for name information.            */     
   %display name_add blank bell;                             

      /* Prompt user for accounting information. The  */     
      /* BLANK and BELL options are used to blank out */     
      /* previous values and ring bell upon display.  */     
   %display money blank bell;                                

      /* Perform data validation and display          */     
      /* additional window if error detected.         */     
      /* Continue until a correct answer is given.    */     
   %if &taxint>400 %then %do;                                
      %do %until(&taxint<=400);                              
         %display taxinter;                                  
      %end;                                                  
      %end;                                                  

      /* adjusted gross income=wages+taxable int      */     
   %let agi=%eval(&wages + &taxint);                         

         /* If you cannot be claimed on another       */     
         /* return, then the total of your standard   */   
         /* deduction and personal exemption          */   
         /* would be $5300.                           */   
      %if &incn=X %then %let sdpe=5300;                    

        /* else compute the standard deduction and    */   
        /* personal exemption(sdpe)                   */   
      %else %do;                                           
      %if &wages<500 %then %let sdpe=500;                  
      %else                                                
      %if 500<&wages and &wages<3250 %then                 
          %let sdpe=&wages;                                
      %else %let sdpe=3250;                                
      %end;                                                

      /* compute taxable income=                      */   
      /* adjusted income - sdpe                       */   
   %let ti=%eval(&agi-&sdpe);                              
      %if &ti<0 %then %let ti=0;                           

      /* Perform DATA STEP calculations. Compute tax  */   
      /* according to table lookup. Format taxcalc is */   
      /* in a permanent format library and not        */   
      /* defined in this article.                     */   
   data _null_;                                            
   call symput('tax',left(put(&ti,taxcalc.)));             
   run;                                                    

      /* Compute amount of refund or tax owed.        */  
      /* Refund=federal income tax withheld -         */
      /* computed tax.                                */
   %let refund=%eval(&fitw-&tax);                        
      %if &refund<0 %then %do;                           
      %let owe=%eval(&tax-&fitw);                        
      %let refund=0;                                     
   %end;                                                 

      /* Display window for refund or amount of       */
      /* tax owed.                                    */
   %if &refund=0 %then %display final.owe;               
      %else %display final.refund;                       
%mend;                                                   

   /* invoke macro T1040EZ with help requested        */
%t1040ez(help=Y) 

                                        
/**********************************************************************/


%window final                                        
   group=owe                                         
#3  @2 ' This group limited for brevity'             
   group=refund                                      
#3  @2 '                Congratulations !' c=red     
#4  @2 ' You are entitled to a REFUND of $'          
       refund protect=yes                            
#6  @2 ' Below is a summary of your tax calculations'
#8  @2 ' Reported wages, salaries, and tips      $'  
       +1 wages                                      
#9  @2 ' Reported taxable interest income        $'  
       +1 taxint                                     
#10 @2 ' Computed Adjusted Gross Income          $'  
       +1 agi                                        
#11 @2 ' Standard Deduction + Personal Exemption $'  
       +1 sdpe                                       
#12 @2 ' Computed Taxable Income                 $'  
       +1 ti                                         
#13 @2 ' Reported Federal Income Tax withheld    $'  
       +1 fitw                                       
#14 @2 ' Computed Federal Income Tax             $'  
       +1 tax                                        
#15 @2 ' Computed Federal Income Tax Refund      $'  
       +1 refund  ;                                  

%display final.refund;                               


/**********************************************************************/