BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
xxformat_com
Barite | Level 11

In dictionaries, the maximum length of format and informat names is 49

I would expect something like 31 for formats (32 -1 for the $) and 30 for informats (32 -1 for the $ and - 1 for the @).

 

proc sql;
    create table tmp as
    select *
    from dictionary.columns
    where upcase(libname)='SASHELP' and
          upcase(memname)='CLASS';
    
    select name, length
    from dictionary.columns
    where upcase(libname)='WORK' and 
          upcase(memname)='TMP' and
          upcase(name) in ('FORMAT','INFORMAT');
quit;

fmtname.JPG

 

 

The length of the FMTNAME variable in format catalogs is 32.

 

proc format;
    value $sex 'M'='Male'
               'F'='Female';
run;

proc format cntlout=chk;
run;

proc print data=sashelp.vcolumn noobs;
    where upcase(libname)='WORK' and 
          upcase(memname)='CHK'  and 
          upcase(name)='FMTNAME';
    var name length;
run;

fmtname2.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The is no inconsistency there.

Two different things. Two different variable names.

 

FMTNAME is the NAME of the format.

FORMAT is the value of the format SPECIFICATION that has been attached to a variable.  So the name plus the optional width plus the period plus the option number of decimal places.

 

You will see an inconsistency between the DICTIONARY tables and the output of PROC CONTENTS.  The dataset generated by PROC CONTENTS has three variable to store the format specification.  The name of the format is in a variable named FORMAT and the width (length) is in FORMATL and the number of decimal places is in FORMATD.  So the variable FORMAT created by PROC CONTENTS has the name of the variable in DICTIONARY.COLUMNS but the content of the variable FMTNAME generated by PROC FORMAT or DICTIONARY.FORMATS.

View solution in original post

4 REPLIES 4
FreelanceReinh
Jade | Level 19

The FMTNAME variable in the CNTLOUT dataset contains the bare (in)format name, which cannot exceed 32 characters. The format and informat variables of dictionary.columns, however, also include the length and decimal specifications (if any), the period (and the dollar sign for character (in)formats, but this doesn't increase the maximum length needed). The example ABCDEFGHIJKLMNOPQRSTUVWXYZFORMAT32767.12345 shows that the length of those variables must be at least 43.

Tom
Super User Tom
Super User

The is no inconsistency there.

Two different things. Two different variable names.

 

FMTNAME is the NAME of the format.

FORMAT is the value of the format SPECIFICATION that has been attached to a variable.  So the name plus the optional width plus the period plus the option number of decimal places.

 

You will see an inconsistency between the DICTIONARY tables and the output of PROC CONTENTS.  The dataset generated by PROC CONTENTS has three variable to store the format specification.  The name of the format is in a variable named FORMAT and the width (length) is in FORMATL and the number of decimal places is in FORMATD.  So the variable FORMAT created by PROC CONTENTS has the name of the variable in DICTIONARY.COLUMNS but the content of the variable FMTNAME generated by PROC FORMAT or DICTIONARY.FORMATS.

xxformat_com
Barite | Level 11

Actually FMTNAME lenght of 32 includes the $ and @.

 

Here is an example you can test. Add any character to the format/informat name and you will see a note in the log indicating that the name is exceeding 32 characters.

 

proc format;
    value   _234567890123456789012345678901_  0='No';  *32 characters;
    invalue _23456789012345678901234567890_   'N'=0;   *31 char + @;
    
    value   $_3456789012345678901234567890_ 'N'='No'; *31 char + $;
    invalue $_345678901234567890123456789_  'N'='No'; *30 char + $ +@;
run;

xxformat_com
Barite | Level 11

So 32 bytes for FORMAT 8 bytes for FORMATD and 8 bytes for FORMATL and 1 byte for the dot.

It would mean that proc sql FORMAT character value would use 8 characters for FORMAT D (converting FORMATD to numeric) and the same for FORMATL? Not sure it makes sense. Right now, I'm reaching my reasoning limits.

If I receive metadata with the three variables and want to create the combined version, I would need to know how to convert it.

 

Then let's also add -R, -L or -C to account for two extra characters meaning planning for 51 in a variable used by putc... functions.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1062 views
  • 4 likes
  • 3 in conversation