LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 22 Sep 2010 15:19:47 -0400
Reply-To:     Tom Abernathy <tom.abernathy@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Tom Abernathy <tom.abernathy@GMAIL.COM>
Subject:      Re: EG Users and Formats

This problem pre-dates EG.

Here is the key section to the FW macro that Tom Hoffman create years ago to generate a where clause to search for formatted values of a variable.

33 %*---------------------------------------------------------------------- 34 Use VAREXIST HC tool to look up variables format. 35 -----------------------------------------------------------------------; 36 %let fmt = %varexist(&syslast,&varname,FMT); 37 %if %length(&fmt) %then 38 where upcase(put(&varname,&fmt)) %upcase(&clause) 39 ; 40 %else 41 where upcase(&varname) %upcase(&clause) 42 ;

Tom Hoffman also created a macro to create formats with the value in the decode from an existing format catalog. He would save the new formats into a CFORMATS catalog and you could just change your FMTSEARCH option to tell it which one to search first. So when running interactively you would use the CFORMATS catalog and get the codes printed with the decodes. When running production quality tables you would revert to the normal decodes.

- Tom Abernathy

On Wed, 22 Sep 2010 12:03:17 -0700, Sterling Paramore <gnilrets@GMAIL.COM> wrote:

>So perhaps my example was a little too simplistic. Here's a real example: > >proc format; > value $GRHLev2f > "COMM" = "Commercial Group" > "MEDAID" = "Medicaid" > "MEDARE" = "Medicare" > "GOVT" = "Other Government Programs" > "NONGRP" = "Other Non-Group" > "PUBLIC" = "Public Group" > other = "ERROR"; >run; > >When the users open up the dataset to look at it, they see the nice >formatted values that should go on any final reports. However, in order to >select a certain group, they have to know what the unformatted value is, and >there's no easy EG-way to do that. I don't like putting the unformatted >value as part of the formatted value, because the unformatted value should >not go on the final report. Furthermore, one of the advantages of using >formats is that I can change the display of the data without changing the >data. For example, suppose that a senior VP suddenly decided that he didn't >want to see Medicare and Medicaid split out. I could easily make that >change by changing the format to: > >proc format; > value $GRHLev2f > "COMM" = "Commercial Group" > "MEDAID" = "Medicaid/Medicare" > "MEDARE" = "Medicaid/Medicare" > "GOVT" = "Other Government Programs" > "NONGRP" = "Other Non-Group" > "PUBLIC" = "Public Group" > other = "ERROR"; >run; > >I wouldn't have to touch the datasets (although of course some reports may >need to be redesigned a bit). > >-Sterling >On Wed, Sep 22, 2010 at 11:03 AM, Joe Matise <snoopy369@gmail.com> wrote: > >> proc format library=library; >> value $test >> "1" = "1 (One)" >> "2" = "2 (Two)" >> "3" = "3 (Three)"; >> run; >> >> is how I'd do it - put the real value and then the label in parentheses. >> >> Joe >> >> >> On Wed, Sep 22, 2010 at 12:35 PM, Sterling Paramore <gnilrets@gmail.com>wrote: >> >>> Dear SAS-L, >>> >>> As a data admin, I love formats. They allow me to change the display of >>> data without changing the content. However, formats confuse and irritate >>> most of my EG users. For example, suppose I have the following dataset: >>> >>> proc format library=library; >>> value $test >>> "1" = "One" >>> "2" = "Two" >>> "3" = "Three"; >>> run; >>> >>> data sasuser.have; >>> input x$; >>> format x $test.; >>> datalines; >>> 1 >>> 2 >>> 3 >>> ; >>> run; >>> >>> >>> >>> In EG, when they open up the dataset, they see "One","Two","Three". >>> Suppose >>> they wanted to just get the "Two" row. When they open up the query >>> builder >>> and filter on x = "Two", they of course do not get any results. >>> Ultimately, >>> they have to know what the unformatted values are in order to use them AND >>> they have to always be aware that a certain column is formatted. While >>> there is an option in the query builder to "Get Values", this only >>> searches >>> the first 100,000 rows of a dataset and some of the datasets I have are >>> much >>> larger than this. >>> >>> How have you handled this dilemma? Up to now, I have mostly avoided using >>> formats in the final datasets because of this, but I'm thinking more and >>> more that they could be very convenient for some features. >>> >>> Thanks, >>> Sterling >>> >> >>


Back to: Top of message | Previous page | Main SAS-L page