Hi, I'm using SAS Studio Enterprise with SAS 9.4 and I'm getting this weird error with proc format:
I'm using a macro to create a format for each variable on my dataset, some of these variables' names end in a number, so I concat an 'f' at the end of each one and make sure none of them exceed the 32 char limit. In theory it should work, but for this variable in particular it's throwing an error when I try to load up the formats using cntlin option:
variable name: HH_IP_AVG_VG_B_3T_SUM_LIMCO_1A6
format name: HH_IP_AVG_VG_B_3T_SUM_LIMCO_1A6f
Error:
ERROR: The format name @HH_IP_AVG_VG_B_3T_SUM_LIMCO_1A6 ends in a number, which is invalid.
But if I look on the dataset under fmtname, it says HH_IP_AVG_VG_B_3T_SUM_LIMCO_1A6f, which is correct.
So I tried creating the format directly using proc format:
proc format cntlout=testformat;
invalue hh_ip_avg_vg_b_3t_sum_limco_1a6f 100-high = 100;
run;
proc format cntlin=testformat; run;
And I get the same error:
70 proc format cntlout=testformat;
71 invalue hh_ip_avg_vg_b_3t_sum_limco_1a6f 100-high = 100;
NOTE: The informat name '@HH_IP_AVG_VG_B_3T_SUM_LIMCO_1A6F' exceeds 32 characters. Only the first 32 characters will be used.
NOTE: Informat HH_IP_AVG_VG_B_3T_SUM_LIMCO_1A6 has been output.
72 run;
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: The data set WORK.TESTFORMAT has 1 observations and 21 variables.
73
74 proc format cntlin=testformat;
ERROR: The format name @HH_IP_AVG_VG_B_3T_SUM_LIMCO_1A6 ends in a number, which is invalid.
74 ! run;
WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1 observations read from the data set WORK.TESTFORMAT.
What is going on here? Where does the '@' come from?
My understanding is that numeric INFORMAT names are stored internally in SAS catalogs with an ampersand on the front. Therefore the maximum length of an INFORMAT name is actually 31 not 32. Numeric FORMAT names allow the full 32 characters as they don't have a preceding ampersand. This limitation is explained clearly here:
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.