Help using Base SAS procedures

Do the START and END values in a user defined format have to be text?

Reply
Contributor
Posts: 61

Do the START and END values in a user defined format have to be text?

Do the START and END values in a user defined format have to be text? I'm trying to use the format as a lookup table to optain the company division/region and area names for each cost center number, to do a report for my company. Currently, the cost center number column on our main reporting dataset is numeric. Will I have to convert it to text to perform the lookup, then convert it back to numeric when the report is output?
Super Contributor
Super Contributor
Posts: 3,174

Re: Do the START and END values in a user defined format have to be text?

PROC FORMAT can generate either a numeric or character format which is dependent on your input variable. See the DOC link below, hosted at the SAS support http://support.sas.com/ website.

Scott Barry
SBBWorks, Inc.

Base SAS Procedures Guide - The FORMAT Procedure
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000063536.htm
Valued Guide
Posts: 2,177

Re: Do the START and END values in a user defined format have to be text?

a format is used as a value is "put".
As such it provides text (often numeric text, but still text)
That seems just fine for output.
If your "output" is to be received in an environment where it is to be treated as numeric (like a database or excel) you'll be able to support the receiving environment with more information, like DBtype option (iirc) through SAS/Access, or tagattr strings through tagsets.excelXP

lots of options available.

PeterC
Super Contributor
Super Contributor
Posts: 3,174

Re: Do the START and END values in a user defined format have to be text?

The question posed by the OP was about START and END, not LABEL. Yes, the LABEL response to a format is character.

Scott Barry
SBBWorks, Inc.
Valued Guide
Posts: 2,177

Re: Do the START and END values in a user defined format have to be text?

Scott

reading the OP question beyond the subjectline question[pre]> I'm trying to use the format as a
> lookup table to optain the company division/region
> and area names for each cost center number,
> Currently, the cost center
> number column on our main reporting dataset is
> numeric. Will I have to convert it to text to
> perform the lookup, [/pre]

I decided to answer the part that you had not already answered.

Chandler's program won't need to convert his cost center number to perform the look-up.(imho)
Would you agree?

PeterC Message was edited by: Peter.C
Super Contributor
Super Contributor
Posts: 3,174

Re: Do the START and END values in a user defined format have to be text?

Who knows how the PUT-returned character data was to be used. Cleary you saw an opportunity and shared beyond the minimum. No fault seen there.

Scott Barry
SBBWorks, Inc.
Contributor
Posts: 61

Re: Do the START and END values in a user defined format have to be text?

Thanks to both of you. Sample numeric cost center ("START) data used in PROC FORMAT below:

START END LABEL
102300 102300 North Georgia
107500 107500 Central Florida

Code in program to generate "North Georgia" label by applying above format:

format bk_grp bk_area $103. ;
bk_area = put(cost_cntr,$z_bkar.) ;
Super Contributor
Super Contributor
Posts: 3,174

Re: Do the START and END values in a user defined format have to be text?

Your use of the PUT function identifies a CHARACTER type format being used, not a NUMERIC format.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 7 replies
  • 116 views
  • 0 likes
  • 3 in conversation