DATA Step, Macro, Functions and more

How can one identify the max length of a format

Accepted Solution Solved
Reply
PROC Star
Posts: 7,468
Accepted Solution

How can one identify the max length of a format

I have a situation where I have to know the maximum length for a formatted variable. I know that I can use proc format to get the value if I know which catalog the format is coming from, but how can I get the value if I'm only passed the format name, but have no idea where it is coming from?

I need to do it programmatically, as it is part of a macro being used to export data.


Accepted Solutions
Solution
‎09-24-2014 06:48 PM
Super User
Posts: 11,343

Re: How can one identify the max length of a format

Search the dictionary.options or sashelp.voptions for the fmtsearch setting value OPTNAME=FMTSEARCH and SETTING so you can search through dictionary.format or sashelp.vformat in the correct order to find the first occurrence of the format with the desired name and associated MAXW.

If you don't have as many format catalogs as I do, then this might be relatively easy.

View solution in original post


All Replies
Super Contributor
Posts: 297

Re: How can one identify the max length of a format

Could you not query the SASHELP.VFORMAT?

DATA TEST;

SET SASHELP.VFORMAT;

RUN;

Solution
‎09-24-2014 06:48 PM
Super User
Posts: 11,343

Re: How can one identify the max length of a format

Search the dictionary.options or sashelp.voptions for the fmtsearch setting value OPTNAME=FMTSEARCH and SETTING so you can search through dictionary.format or sashelp.vformat in the correct order to find the first occurrence of the format with the desired name and associated MAXW.

If you don't have as many format catalogs as I do, then this might be relatively easy.

PROC Star
Posts: 7,468

Re: How can one identify the max length of a format

You are both correct of course. It's been a loooooooooooong day!  Much appreciated!

Occasional Contributor
Posts: 13

Re: How can one identify the max length of a format

Will VFORMATW do what you are looking for?

PROC Star
Posts: 7,468

Re: How can one identify the max length of a format

vformatwx might do what I need

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 287 views
  • 7 likes
  • 4 in conversation