![]() | ![]() | ![]() | ![]() | ![]() |
You can create more than one format from an input control data set with PROC FORMAT. The input control data set must contain the variables FMTNAME, START, and LABEL. In this sample, the TYPE variable has been added with the value of "C" to create multiple character formats.
Please see the code in the Full Code tab for an example.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
options formdlim=' ';
data format;
input OccCode $ OccCode_formatted $23. name $ region $;
cards;
0 None John NE
27 Laborer Mary NW
3 Service Sue SE
4 Service Administration Peter SW
15 Engineer Paul CENTRAL
;
run;
data cntlone;
set format;
fmtname="$OccCode";
start=OccCode;
label=OccCode_formatted;
type='C';
output ;
fmtname="$Region";
start=region;
type='C';
if region in('NE' 'NW') then label='North';
else if region in('SE' 'SW') then label='South';
else label=region;
output ;
run;
/* Sort the CNTLIN data set to group format rows together */
proc sort data=cntlone;
by fmtname start;
run;
proc format cntlin=cntlone;
run;
/* For debugging purposes, verify that formats are on the library */
options linesize=120;
proc format library=work fmtlib;
select $OccCode $Region;
run;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
---------------------------------------------------------------------------- | FORMAT NAME: $OCCCODE LENGTH: 22 NUMBER OF VALUES: 5 | | MIN LENGTH: 1 MAX LENGTH: 40 DEFAULT LENGTH 22 FUZZ: 0 | |--------------------------------------------------------------------------| |START |END |LABEL (VER. V7|V8 14OCT2009:20:32:22)| |----------------+----------------+----------------------------------------| |0 |0 |None | |15 |15 |Engineer | |27 |27 |Laborer | |3 |3 |Service | |4 |4 |Service Administration | ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- | FORMAT NAME: $REGION LENGTH: 7 NUMBER OF VALUES: 5 | | MIN LENGTH: 1 MAX LENGTH: 40 DEFAULT LENGTH 7 FUZZ: 0 | |--------------------------------------------------------------------------| |START |END |LABEL (VER. V7|V8 14OCT2009:20:32:22)| |----------------+----------------+----------------------------------------| |CENTRAL |CENTRAL |CENTRAL | |NE |NE |North | |NW |NW |North | |SE |SE |South | |SW |SW |South | ----------------------------------------------------------------------------
| Type: | Sample |
| Topic: | Common Programming Tasks ==> Selecting Data Common Programming Tasks ==> Working with Character Data Data Management ==> Data Sources ==> SAS catalogs Data Management ==> Data Sources ==> SAS Data Sets/Tables Data Management ==> Data Sources ==> SAS Libraries Data Management ==> Manipulation and Transformation ==> User Written Formats |
| Date Modified: | 2010-04-16 10:34:14 |
| Date Created: | 2009-10-14 20:05:03 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | N/A | IRIX | ||
| HP-UX | ||||
| ABI+ for Intel Architecture | ||||
| 64-bit Enabled HP-UX | ||||
| 64-bit Enabled Solaris | ||||
| Windows Vista | ||||
| 64-bit Enabled AIX | ||||
| Windows Millennium Edition (Me) | ||||
| Microsoft Windows 95/98 | ||||
| Microsoft Windows 2000 Advanced Server | ||||
| Microsoft Windows 2000 Datacenter Server | ||||
| Microsoft Windows 2000 Server | ||||
| Microsoft Windows NT Workstation | ||||
| Microsoft Windows Server 2003 Datacenter Edition | ||||
| Microsoft Windows Server 2003 Enterprise Edition | ||||
| Microsoft Windows Server 2003 Standard Edition | ||||
| Microsoft Windows Server 2008 | ||||
| Linux | ||||
| Linux for x64 | ||||
| Linux on Itanium | ||||
| OpenVMS Alpha | ||||
| OpenVMS on HP Integrity | ||||
| Macintosh on x64 | ||||
| Microsoft Windows 2000 Professional | ||||
| Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
| Microsoft Windows XP 64-bit Edition | ||||
| Microsoft® Windows® for x64 | ||||
| OS/2 | ||||
| OpenVMS VAX | ||||
| Macintosh | ||||
| HP-UX IPF | ||||
| AIX | ||||
| Microsoft Windows XP Professional | ||||
| Microsoft Windows 7 | ||||
| z/OS | ||||
| Solaris for x64 | ||||
| Tru64 UNIX | ||||
| Solaris | ||||




