DATA Step, Macro, Functions and more

Filter blank columns at print

Posts: 1

Filter blank columns at print

I have a large dataset with dates as columns.  Actually the columns are a simulated date (_YYYYMMDD_) stored in a macro variable, but that's a whole other issue.  I then print this data by an ID with those dynamic dates.  However, some of the data may have data on Monday, Wednesday and Friday whereas other data may have just Monday and Wednesday.  Since the macro variable contains all valid days stored for the complete set of data, the IDs that only have Monday and Wednesday will always have that blank column for Friday.  I want to only have non-blank columns print on each by group.  Is this possible without completely re-writing the way I store the data.

ID  _20161102_  _20161104_  _20161107_  _20161109_  _20161111_

1           12                 22                  33                    12               33

2             7                   .                   22                     11                .


When 1 is printed I want it to have all columns, but 2 should only show the days/columnswhen there is data. 



Super User
Posts: 23,980

Re: Filter blank columns at print

Posted in reply to mikeydubs23

You would be better off storing the data in a long format and then reporting using a proc report and Across or proc tabulate.


Let's assume that's not possible for some reason.


Based on your variable list you can compute statistics, and if the NMISS is equal to the total number of observations then you can select those column names for your final report. 


There's no simple filter in proc print that I'm aware of.



Super User
Posts: 6,921

Re: Filter blank columns at print

Posted in reply to mikeydubs23

It's work, but you can do it by using customized reporting (a DATA step with FILE an PUT statements to generate the report).  Your DATA step skills will need to be good (including familiarity with arrays plus a firm grasp of what you want the report to look like) to make this happen.

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation