2014-03-23

updating

← Older revision

Revision as of 13:16, 23 March 2014

(3 intermediate revisions by one user not shown)

Line 1:

Line 1:

 

 

 

 



Coders Corner, SUGI 23 Nancy K. Patton, ASG, Inc.

+

Coders Corner, SUGI 23
(1998)
Nancy K. Patton, ASG, Inc.

 

+

 

 

+

NESUG 98

 

 

 

ABSTRACT (CNTLIN=)

 

ABSTRACT (CNTLIN=)

Line 9:

Line 11:

 

Using the SAS® system and the CNTLIN= option in PROC FORMAT, a format can be defined where all the account numbers you want identified are set to a value of ‘KEEP”. By using the PUT function to apply that format to the account numbers as you read the flat files, you could identify the records with the accounts you are looking for and control their destiny!.

 

Using the SAS® system and the CNTLIN= option in PROC FORMAT, a format can be defined where all the account numbers you want identified are set to a value of ‘KEEP”. By using the PUT function to apply that format to the account numbers as you read the flat files, you could identify the records with the accounts you are looking for and control their destiny!.

 

 



This example will make the look-up process simple to understand and easy to bring back to work!ABSTRACT (CNTLOUT=)

+

This example will make the look-up process simple to understand and easy to bring back to work!

 

+

 

 

+

ABSTRACT (CNTLOUT=)

 

 

 

Have you ever hard-coded a ‘dummy’ data set to combine with your data in order to force all categories of a formatted CLASS variable in PROC SUMMARY be included in your output? You could have used CNTLOUT= option and created that dataset quite easily!

 

Have you ever hard-coded a ‘dummy’ data set to combine with your data in order to force all categories of a formatted CLASS variable in PROC SUMMARY be included in your output? You could have used CNTLOUT= option and created that dataset quite easily!

Line 16:

Line 20:

 

 

 

HOW TO: PROC FORMAT CNTLIN=

 

HOW TO: PROC FORMAT CNTLIN=

 

+

 

First you must define the account numbers in a SAS data set, and create variables PROC FORMAT needs in order to produce a format using CNTLIN=. In this example you only need to use the variables START, LABEL and FMTNAME. Other variables are documented.

 

First you must define the account numbers in a SAS data set, and create variables PROC FORMAT needs in order to produce a format using CNTLIN=. In this example you only need to use the variables START, LABEL and FMTNAME. Other variables are documented.

 

 

Line 55:

Line 60:

 

 

 

 



HOW TO: PROC FORMAT
CNTLOUTThe
CNTLOUT= option needs to be added to the PROC FORMAT when creating the format to be used on the CLASS variable. This will create a CNTLOUT data set.

+

HOW TO: PROC FORMAT
CNTLOUT

 

+

 

 

+

The
CNTLOUT= option needs to be added to the PROC FORMAT when creating the format to be used on the CLASS variable. This will create a CNTLOUT data set.

 

 

 

  PROC FORMAT CNTLOUT=FMTOUT;

 

  PROC FORMAT CNTLOUT=FMTOUT;

Line 76:

Line 83:

 

 

 

  700-799 = 700

 

  700-799 = 700



 

 

  800-899 = 800

 

  800-899 = 800



 

 

  900-999 = 900;

 

  900-999 = 900;

 

+

 

+

 

+

 

+

The data set FMTOUT consists of variables that give information about each format and informat created. We need to pay attention to the variable FMTNAME to select those variables in only the DISTRIB format. The LABEL variable will hold the actual value used to format the CLASS variables so it will be renamed to match. The other variables are documented and not necessary for this example.

 

+

%MACRO FILLDATA;

 

+

DATA FILL ;

 

+

SET FMTOUT ;

 

+

IF FMTNAME = 'DISTRIB' ;

 

+

KEEP LABEL ;

 

+

RENAME LABEL = CLSSVAR ;

 

+

 

+

%MEND FILLDATA;

 

+

After calling and executing the macro FILLDATA, a SAS data set FILL is created. This can be appended to your data to force all classifications in the format to appear in the output of your PROC SUMMARY.

 

+

 

+

 

+

%FILLDATA ;

 

+

 

+

DATA DIST1;

 

+

 

+

SET SUGIDATA.DATA FILL ;

 

+

 

+

CLSSVAR =

 

+

 

+

PUT(INPUT(GMSCORE),DISTRIB.);

 

+

 

+

PROC SUMMARY

 

+

 

+

NWAY MISSING DATA = DIST1;

 

+

 

+

CLASS CLSSVAR;

 

+

VAR AMOUNT;

 

+

OUTPUT SUM= OUT=SUMM;

 

+

 

+

 

+

The data set DIST1 is made up of the raw data SUGIDATA.DATA and the data set FILL which you just created. After PROC SUMMARY is run on DIST1, the classification variable CLSSVAR will have each value in the format DISTRIB.

 

+

 

+

 

+

CONCLUSION

 

+

PROC FORMAT is an invaluable tool to use for reporting. PROC FORMAT in conjunction with CNTLIN= or CNTLOUT= gives you the ability to build formats from data and to use the formats to force classification variables to have values for all values of the format whether there is data or not.

 

+

 

+

 

+

 

+

 

+

SAS is a registered trademark or trademark of SAS

 

+

 

+

 

+

Institute Inc. in the USA and other countries. ®  indicates a USA registration

 

 

 

 

 

Coders' Corner

 

Coders' Corner

 

+

[[Category:NancyWilson Papers and Presentations]]

 

+

[[Category:Formats]]

 

+

[[Category:SUGI 1998]]

 

+

[[Category:NESUG]]

Show more