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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.