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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.