Technology Tales

Adventures in consumer and enterprise technology

Setting VIEWTABLE to show column names in SAS

Published on 15th September 2011 Estimated Reading Time: 3 minutes

The following is the default behaviour in the DMS: Base SAS opens datasets from its Explorer using VIEWTABLE and with variable labels in the column headings and not variable names. Because I have been fortunate to use systems with SAS/FSP both installed and licensed, I have taken to using FSVIEW for browsing SAS datasets as a workaround and, though the interface may look old to some, it proves to be a very flexible tool that still has a few things to teach newer ones. With SAS Enterprise Guide, the dataset viewing functionality is different to both VIEWTABLE and FSVIEW, but I have been to make it work for me. While the SAS EG dataset viewing tool may appear like the former of these, it has a few tricks to teach its forbear.

Now that I find myself working again with the traditional SAS DMS interface and without SAS/FSP, I decided to see if there was a way to get VIEWTABLE to display variable names instead of variable labels by default. As it happened, the answer was found in an internet forum discussion. From the SAS command line, you can achieve the result by issuing a command like the following:

VT SASHELP.VCOLUMN COLHEADING=NAMES

Above VT is the VIEWTABLE shortcut, while it is the COLHEADING=NAMES option on the line that gets variable names shown in column headings. Taking it further, you can set this as the default setting for datasets opened using a mouse from Explorer panes using the following procedure:

  • Click in or on the Explorer pane to highlight the Explorer window.
  • Select Tools > Options > Explorer in the menus.
  • Select the Members tab.
  • Double-click on the TABLE icon.
  • Double-click on the &Open action.
  • Set the Action command to:  VIEWTABLE %8b.'%s'.DATA COLHEADING=NAMES.
  • Click on the Set Default button.
  • Save changes and close the Explorer Options window.

Because the DMS looks similar across versions 8.0 through to 9.2, the above instructions should be relevant to all of those. While I have yet to get the opportunity to use SAS 9.3, I would be surprised to find that the traditional SAS interface has changed there too, even though much else has changed about SAS. In fact, the latest version of SAS has brought quite a few interesting new features for programmers, so it appears that you can do more through a familiar interface, not entirely a bad thing. It looks as if this VIEWTABLE tweak could be useful for a while yet.

Comments:

  • Cherie says:

    this action blew away all my tables in my local worklib. Have to re-run now.

    • John says:

      That sounds odd because surely it would take either a PROC DATASETS or a PROC SQL step to do that kind of thing. It never happened on me. Or did you end up closing an interactive SAS session and restart it? That would explain what you saw.

  • Cherie says:

    correction didn't blow them away, but upon open it show 0 obs. I reverted back to old code and now I can see my tables again.

    • John says:

      Good to hear that you still have your datasets. Still strange to hear that change meant that no records could be seen in them though. Issuing NAMES in the SAS command line will switch between variable names and labels for you anyway, unless you are using Enterprise Guide and that is another matter.

  • VK says:

    Wonderful solution! Finally getting rid of variable descriptions which get set when you rename variables during a data step.

  • cc says:

    Great Guide ! Thanks !!!!

  • The content, images, and materials on this website are protected by copyright law and may not be reproduced, distributed, transmitted, displayed, or published in any form without the prior written permission of the copyright holder. All trademarks, logos, and brand names mentioned on this website are the property of their respective owners. Unauthorised use or duplication of these materials may violate copyright, trademark and other applicable laws, and could result in criminal or civil penalties.

  • All comments on this website are moderated and should contribute meaningfully to the discussion. We welcome diverse viewpoints expressed respectfully, but reserve the right to remove any comments containing hate speech, profanity, personal attacks, spam, promotional content or other inappropriate material without notice. Please note that comment moderation may take up to 24 hours, and that repeatedly violating these guidelines may result in being banned from future participation.

  • By submitting a comment, you grant us the right to publish and edit it as needed, whilst retaining your ownership of the content. Your email address will never be published or shared, though it is required for moderation purposes.