BookmarkSubscribeRSS Feed
chandler
Fluorite | Level 6
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?
7 REPLIES 7
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
Peter_C
Rhodochrosite | Level 12
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
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
Peter_C
Rhodochrosite | Level 12
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
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
chandler
Fluorite | Level 6
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.) ;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Your use of the PUT function identifies a CHARACTER type format being used, not a NUMERIC format.

Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 820 views
  • 0 likes
  • 3 in conversation