I am struggling to understand an issue about an uninitialized value in a variable that I use in a COMPUTE block that does not have a missing value. I have used this approach before. I got the hint on this board from Cynthia Zender. If I change to a character version, no issue are reported and the report is formatted as intended.
8748 data __folder_transferred ;
8749 set __folder_transferred ;
8750 levelc = put( level , 8. -L ) ;
8751 run ;
NOTE: There were 700 observations read from the data set WORK.__FOLDER_TRANSFERRED.
NOTE: The data set WORK.__FOLDER_TRANSFERRED has 700 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
8752
8753 ods listing close ;
8754
8755 ods rtf file = "XXXXX.rtf" newfile = none startpage = no ;
NOTE: Writing RTF Body file: XXXXX.rtf
8756
8757 proc report data = __folder_transferred style( header ) = { just = l } style( report ) = { width = 100% rules = none } style( column ) = { borderstyle = none rules = none bordercolor = red } ;
8758 column ( "Section II. Files Transferred" "`{style [ fontweight = medium backgroundcolor = lightgrey ]Provide file information below (e.g., package names, individual file names, sizes, etc.).}"
8759 group level file size units
8760 ) ;
8761 define group / noprint order ;
8762 define level / noprint ;
8763 define file / " " style ( column ) = { cellwidth = 70% just = l } ;
8764 define size / " " style ( column ) = { cellwidth = 20% just = r } format = comma9. ;
8765 define units / " " style ( column ) = { cellwidth = 8% just = l } ;
8766 compute before group / style = { fontweight = bold just = l backgroundcolor = lightgrey } ;
8767 length text $ 100 ;
8768 if group = 0 then text = "Files Transferred:" ;
8769 else text = "Individual File Names:" ;
8770 line text $100. ;
8771 endcomp ;
8772
8773 compute file ;
8774 if level = 1 then call define ( _col_ , "style" , "style = { leftmargin = 4% }" ) ;
8775 else if level = 2 then call define ( _col_ , "style" , "style = { leftmargin = 8% }" ) ;
8776 endcomp ;
8777
8778 run ;
NOTE: Variable level is uninitialized.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.74 seconds
cpu time 0.46 seconds
NOTE: There were 700 observations read from the data set WORK.__FOLDER_TRANSFERRED.
8779
8780 proc report data = __folder_transferred style( header ) = { just = l } style( report ) = { width = 100% rules = none } style( column ) = { borderstyle = none rules = none bordercolor = red } ;
8781 column ( "Section II. Files Transferred" "`{style [ fontweight = medium backgroundcolor = lightgrey ]Provide file information below (e.g., package names, individual file names, sizes, etc.).}"
8782 group levelc file size units
8783 ) ;
8784 define group / noprint order ;
8785 define levelc / noprint ;
8786 define file / " " style ( column ) = { cellwidth = 70% just = l } ;
8787 define size / " " style ( column ) = { cellwidth = 20% just = r } format = comma9. ;
8788 define units / " " style ( column ) = { cellwidth = 8% just = l } ;
8789 compute before group / style = { fontweight = bold just = l backgroundcolor = lightgrey } ;
8790 length text $ 100 ;
8791 if group = 0 then text = "Files Transferred:" ;
8792 else text = "Individual File Names:" ;
8793 line text $100. ;
8794 endcomp ;
8795
8796 compute file ;
8797 if levelc = "1" then call define ( _col_ , "style" , "style = { leftmargin = 4% }" ) ;
8798 else if levelc = "2" then call define ( _col_ , "style" , "style = { leftmargin = 8% }" ) ;
8799 endcomp ;
8800
8801 run ;
NOTE: There were 700 observations read from the data set WORK.__FOLDER_TRANSFERRED.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.08 seconds
cpu time 0.07 seconds
8802
8803
8804 ods rtf close ;
8805 ods listing ;
As you can see, the data step does not report a missing value. The second REPORT procedure, a copy of the first with LEVEL replaced by LEVELC, runs without issues.
Does anyone see what I am overlooking?
Thank you,
Kevin
After I posted, the ORDER option to the DEFINE statement caught my eye. Adding ORDER to the DEFINE statement for LEVEL resolves the issue. I will not have a think about the process 🙂
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.