Date: Thu, 2 Aug 2007 18:12:01 -0400
Reply-To: Randy Herbison <RandyHerbison@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Randy Herbison <RandyHerbison@WESTAT.COM>
Subject: FW: Unformatted values in SAS Explorer
Content-Type: text/plain; charset="us-ascii"
I wrote: You could add another custom command to the EXECCMD method to
toggle the user-assigned formats back on (you would need to store the
user-assigned format names to make them available for restoration).
I should've written: You could add another custom command to the EXECCMD
method to toggle the user-assigned formats back on. The user-assigned
formats are available from the SAS metadata.
-Randy
-----Original Message-----
From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
On Behalf Of Randy Herbison
Sent: Thursday, August 02, 2007 5:23 PM
To: ckxplus@yahoo.com; SAS-L@listserv.uga.edu
Subject: RE: Unformatted values in SAS Explorer
John,
Assuming that you are using VIEWTABLE (VT) to view the data, I think the
short answer is no. As far as I know, VT always uses formats. If a
column does not have a user assigned format, VT uses defaults (best. for
num vars and $w. for char vars).
There are several ways to make VT use default formats instead of
user-assigned formats.
If you do not have SAS/AF, you can use the GSUBMIT command, in a SAS
Explorer action command, to make an unformatted copy of the data
on-the-fly (inefficient).
If you have SAS/AF, you can use model SCL or the VT command's EXECCMD
argument. Either will require that you specify format widths for char
vars. You can use best. for num vars, and the default width is 12. If
you use $. for char vars, VT will set the format width to 1.
If using model SCL, reset the formats in the DFINIT label. You won't be
able to toggle user-assigned/default formats this way, but you can set
all formats to defaults while VT initializes.
Here's how it might look if you use the VT command's EXECCMD argument:
execcmd: method inCmd :char
retCode :num
optional=outCmd :char;
dcl list dsAttr={},
char(32) column,
char(1) type;
_self_._getDataSetAttributes(dsAttr);
if inCmd='LOSEFORMATS' then do;
do i=1 to listlen(getniteml(dsAttr,'COLUMN_LIST'));
column=getitemc(getniteml(dsAttr,'COLUMN_LIST'),i);
_self_._getColumnAttribute(column,'type',type);
if type='N' then
_self_._setColumnAttribute(column,'format','best.');
else _self_._setColumnAttribute(column,'format','$8.');
end;
retCode=1;
end;
else do;
retCode=0;
call super(_self_, '_execCommand', inCmd, retCode, outCmd); end;
_self_=_self_;
endmethod;
The EXECCMD command argument is used to implement custom command
processing. The custom command I use here is LOSEFORMATS.
The Explorer action command is:
VIEWTABLE %8b.'%s'.DATA execcmd=sasuser.vt_tools.execcmd2.scl:execcmd;
loseformats
The LOSEFORMATS command gets processed immediately after the table is
opened by VT.
You could add another custom command to the EXECCMD method to toggle the
user-assigned formats back on (you would need to store the user-assigned
format names to make them available for restoration).
Another way to do this would involve persisting VT run time
customizations made by the user. EXECCMD is good for that too, but it's
a lot more complicated than the example above. I'll explain how if you
are interested.
-Randy
-----Original Message-----
From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
On Behalf Of ckxplus@yahoo.com
Sent: Thursday, August 02, 2007 3:11 AM
To: sas-l@uga.edu
Subject: Unformatted values in SAS Explorer
I was wondering if there's a way to toggle the display of formatted and
unformatted variables when viewing a SAS dataset with the SAS Explorer.
I've found how to configure the Explorer to show variable names instead
of labels and to show the contents of a format if I double-click on it.
Now I'm wondering if there's some way to show unformatted values instead
of the default formatted values.
Advance thanks for any help,
John Hendrickx