Desktop productivity for business analysts and programmers

Data types and Data Groups

Reply
Frequent Contributor
Posts: 139

Data types and Data Groups

Does anyone know how SAS EG determines whether numeric data is
1) currency
2) date
3) time
4) plain numeric

I was looking throught the sashelp.views and could not find a table that grouped the numeric formats.

Any help would be appreciated

Thanks
N/A
Posts: 0

Re: Data types and Data Groups

1) It inherits formats from the source table/dataset.

2) In the EG Help, look in the index for FORMATS
N/A
Posts: 0

Re: Data types and Data Groups

Another thing to look at for available formats is in the query dialog.

Open the dialog
In the Select Data tab, select a field.
To the right, there are a number of small icons, the one at the top looks like a table grid with a pencil, click on that one.
A popup window will pop up -- imagine that.
for "Format:" click on the "Change" button.
Another popu dialog will pop up, revealing a list of categories of formats, and for each category, a list of formats.

Have fun.
SAS Super FREQ
Posts: 8,819

Re: Data types and Data Groups

Hi:
When SAS stores your data, it only has 2 data types: character variables and numeric variables. SAS EG and the SAS Enterprise Intelligence Platform check the descriptor portion of the SAS data set (or the Metadata for the data set) to determine whether a FORMAT (or INFORMAT) has been applied to a numeric variable. The FORMAT is used to set how your variable will be DISPLAYed on a report. The INFORMAT is used to set how your variable will be READ-IN to SAS (or how you must TYPE in the data if you are entering it yourself.)

For example, in the SASHELP library, there is a data set called CLASS that has an AGE variable. AGE is a numeric variable. If you open an EG project and put SASHELP.CLASS into the project, you will see the standard "numeric" icon for the AGE variable -- because it does not have any FORMAT assigned, EG uses the blue circle with the numbers for the AGE icon. If you add SASHELP.PRDSALE to the project, you will see the "currency" icon for ACTUAL and PREDICT -- ACTUAL and PREDICT have the DOLLAR12.2 format applied to them -- so EG shows them with the "currency" icon.

SAS Enterprise Guide Help has the following topics that may be of interest to you:
Creating New Data ( This topic talks about the difference between DISPLAY format and READ-IN format. )
Working with Data ( This topic shows the default formats for display and informats for reading in data):
[pre]
Data type Format Informat
Character $w. $w.
Numeric BESTw.d w.d
Date MMDDYYw.d MMDDYYw.d
Time TIMEw.d Timew.d
Currency DOLLARw.d none
[/pre]

These are the default FORMATs and INFORMATs that SAS will use. If you want to find out what other formats and/or informats are available to use, look for these help topics:
Formats: Formats by Category
Informats: Informats by Category

I don't know what you mean when you say you are looking for a "table that grouped the numeric formats" -- however the above topics in the documentation might help you decide what format you want to use if you want to change the default described above.
cynthia
Frequent Contributor
Posts: 139

Re: Data types and Data Groups

Hello Cynthia

I was looking for a table in side of SAS that would describe numeric data.

FORMAT DATAGROUP
date. date
8. numeric
$ character
datetime .date
comma numeric
..
etc

But your suggestion of searching for Formats by Category, I can create a table manually

-D
SAS Super FREQ
Posts: 8,819

Re: Data types and Data Groups

Hi:
I'm not sure I understand what the purpose would be of having the format list in a data set.

Most of the places in EG where you can PICK a format have a drop down box with the list of formats in it. The nice thing about the drop down boxes is that each format has a minimum length and a maximum length that it can be -- and that intelligence is built into the places where you can select a format.

In fact, most of the places where you can PICK the format from a drop-down box, also have an area in which it displays what the format looks like.

And, we didn't even go into User-defined formats. So for example, in SASHELP.CLASS, I could design a format that would allow me to show ages according to these groups in one report:
Under 13
Over 13

and according to these categories or groups in another report:
Pre-Teen
Teen
16 and Over

AND, some procedures even support the use of Multi-label formats -- so I could count the same variable in more than 1 group in the same report.

But...if you're happy with what you found, then that's good.

cynthia
N/A
Posts: 0

Re: Data types and Data Groups

Proc Contents will give you a list of variables and their properties inside a particular dataset.

Otherwise, what you may be looking for is called MetaData and should be stored in a MetaData server, setup by someone in your company, and appropriately populated with the metadata by people from within your company.
Valued Guide
Posts: 2,177

Re: Data types and Data Groups

of course, SAS9 brought us the SAS.VFORMAT dictionary of all formats and informats currently available through the libraries and catalogs defined in the FMTSEARCHPATH system option, as well as the built-in formats.
I expect it is from this dictionary table that E.G. builds the format-picking lists

It is a very useful resource, but needs consideration and the understanding you get (take for granted?) automatically with something like SAS Enterprise Guide

PeterC
N/A
Posts: 0

Re: Data types and Data Groups

Peter,

You keep mentioning libraries and "dictionaries" that I do not see, nor find. How can we use SAS.anything unless someone has created the SAS library? It does not appear to be available with our default installation, as I did the install on my PC when it go upgraded last time. Could you help us out a bit more?

1 libname sas list;
ERROR: Libname SAS is not assigned.
ERROR: Error in the LIBNAME statement.

2 proc options option=fmtsearchpath;
3 run;

SAS (r) Proprietary Software Release 9.1 TS1M3

ERROR: Unrecognized SAS option name, FMTSEARCHPATH. Message was edited by: Chuck
Frequent Contributor
Posts: 139

Re: Data types and Data Groups

Unfortunately sashelp.vformat or DICTIONARY.FORMAT does not have the group (date, currency, time, etc.) for the format.

I'm running a messy ETL routine and the customer wants to know which fields are currency, date, datetime values etc. I could just manually look at it, but have SAS do the "thinking" for me would be cool

D
N/A
Posts: 0

Re: Data types and Data Groups

Again, I think we need to re-iterate that SAS has only 2 data types: number and character. Everything else is a matter of formats.

If you want SAS to tell you what the formats that are related to a variable in a dataset, then use the PROC CONTENTS procedure.

If you want a central location for variable definitions, SAS does a have a solution = the SAS MetaData Server. It will discover a lot of information about data when it is imported/incorporated. But, the details of the meanings of a variable has to be manually entered by a human somewhere, by someone who knows.

data demo;
number = 123456789;
number1 = number;
number2 = number;
number3 = number;
number4 = number;
format number1 ssn. number2 datetime. number3 date. number4 time.;
run;
quit;

proc print;
run;
quit;

proc contents data=demo;
run;
quit;

------------------------------------------------------------------
The SAS System 09:24 Tuesday, February 5, 2008 4

Obs number number1 number2 number3 number4

1 123456789 123-45-6789 29NOV63:21:33:09 ******* 34293:33


The SAS System 09:24 Tuesday, February 5, 2008 5

The CONTENTS Procedure

Data Set Name WORK.DEMO Observations 1
Member Type DATA Variables 5
Engine V9 Indexes 0
Created Tuesday, February 05, 2008 09:24:29 AM Observation Length 40
Last Modified Tuesday, February 05, 2008 09:24:29 AM Deleted Observations 0
Protection Compressed NO
Data Set Type Sorted NO
Label
Data Representation WINDOWS_32
Encoding wlatin1 Western (Windows)


Engine/Host Dependent Information

Data Set Page Size 65536
Number of Data Set Pages 1
First Data Page 1
Max Obs per Page 1632
Obs in First Data Page 1
Number of Data Set Repairs 0
File Name E:\sas_work\_TD3416\demo.sas7bdat
Release Created 9.0101M3
Host Created XP_PRO


Alphabetic List of Variables and Attributes

# Variable Type Len Format

1 number Num 8
2 number1 Num 8 SSN.
3 number2 Num 8 DATETIME.
4 number3 Num 8 DATE.
5 number4 Num 8 TIME.
N/A
Posts: 0

Re: Data types and Data Groups

sorry about my typos.

I was referring to SASHELP.VFORMAT, for which proc contents will reveal lots of info, but probably not enough. try the support.sas.com knowledge base.

The format search path option, is not FMTSEARCHPATH as you point out, but
FMTSEARCH

Although this dictionary table does not indicate the appropriate data types for each (in)format, you might find it useful to try each out in an interactive window, but for that I think you would have to leave EG and use interactive SAS Display Manager.

Good Luck, and sorry about the distracting typos

PeterC
Community Manager
Posts: 2,889

Re: Data types and Data Groups

To clear up the question "how does EG do it", it basically categorizes them based on format. Those with a DATE format are Date, those with a currency format (like DOLLAR12.) are Currency, etc.

EG does use some information served up by the IOM FormatService, an API provided by SAS Integration Technologies.

http://support.sas.com/rnd/itech/doc9/dev_guide/dist-obj/comdoc/fmtsca.html

I'm not sure whether the same information is easily accessible using SAS code.

Chris
SAS Super FREQ
Posts: 8,819

Re: Data types and Data Groups

This code works for me to reveal the formats available. There is an extensive list and these formats, by themselves, are meaningless -- this is the list of what's available for formatting numbers: (you should not need a libname statement for SASHELP)
[pre]
proc print data=sashelp.vformat;
var fmtname source minw mind maxw maxd defw defd;
title 'Available Formats';
run;
[/pre]

And this paper talks about all of the "SASHELP.Vxxx" tables for finding out information on your data.
http://www2.sas.com/proceedings/sugi29/237-29.pdf

I would find this report to be more useful. What formats are used in SASHELP.PRDSALE and SASHELP.CLASS? (Or, what formats are being used in your data files of interest??)
[pre]
proc print data=sashelp.vcolumn;
where libname = 'SASHELP' and
memname in ('CLASS', 'PRDSALE');
title 'What Formats are Used for These 2 Tables';
var libname memname memtype name type length format informat label;
run;
[/pre]
And this is the output in the LISTING window. You can see that there are only 2 TYPEs for variables, char or num ... but some variables have formats assigned:
[pre]
What Formats are Used for These 2 Tables

Obs libname memname memtype name type length format informat label
1474 SASHELP CLASS DATA Name char 8
1475 SASHELP CLASS DATA Sex char 1
1476 SASHELP CLASS DATA Age num 8
1477 SASHELP CLASS DATA Height num 8
1478 SASHELP CLASS DATA Weight num 8
2333 SASHELP PRDSALE DATA ACTUAL num 8 DOLLAR12.2 Actual Sales
2334 SASHELP PRDSALE DATA PREDICT num 8 DOLLAR12.2 Predicted Sales
2335 SASHELP PRDSALE DATA COUNTRY char 10 $CHAR10. Country
2336 SASHELP PRDSALE DATA REGION char 10 $CHAR10. Region
2337 SASHELP PRDSALE DATA DIVISION char 10 $CHAR10. Division
2338 SASHELP PRDSALE DATA PRODTYPE char 10 $CHAR10. Product type
2339 SASHELP PRDSALE DATA PRODUCT char 10 $CHAR10. Product
2340 SASHELP PRDSALE DATA QUARTER num 8 8. Quarter
2341 SASHELP PRDSALE DATA YEAR num 8 4. Year
2342 SASHELP PRDSALE DATA MONTH num 8 MONNAME3. Month
[/pre]

It was my understanding that the SASHELP.Vxxx tables were available when you SAS session started -- I don't know when that is on the server machine. But on my machine, these SASHELP files and the SQL DICTIONARY. equivalents are available throughout my entire session.

cynthia

(ps...I just double checked and from a code node, the above code does work in EG.)
Ask a Question
Discussion stats
  • 13 replies
  • 288 views
  • 0 likes
  • 5 in conversation