Hi experts,
In a datastep (or any other way) how do I know if the format associated with some column in the dataset is a built-in format or a user-written format?
Thanks!
You can query SASHELP.VFORMAT
If the variable LIBNAME is missing, then it is a built-in format. Otherwise, it is user created.
You can query SASHELP.VFORMAT
If the variable LIBNAME is missing, then it is a built-in format. Otherwise, it is user created.
Turns out there is a pre-built view called sashelp.vcformat which lists only user-written formats
You can't tell from the code which formats are user-defined, but you can programmatically list all formats available in your SAS session and identify which ones are user-defined like this (user-defined formats will be at the top of the list):
proc sql;
select fmtname
,case
when memname is null then 'Built-in'
else 'User-defined'
end as Source
from dictionary.formats
order by 3 desc, 2, 1
;
quit;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.