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.
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.
Could you not query the SASHELP.VFORMAT?
DATA TEST;
SET SASHELP.VFORMAT;
RUN;
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.
You are both correct of course. It's been a loooooooooooong day! Much appreciated!
Will VFORMATW do what you are looking for?
vformatwx might do what I need
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.