I simply tried defining a new format on SAS studio. The following is my code and the error msg is as in the title. Can anyone help? Thanks a lot!
data countries;
input Start $ Label $;
retain FmtName 'countries';
datalines;
'AU' 'Austr'
'CH' 'China'
;
proc format library=orion.MyMacFmts1 fmtlib cntlin=countries;
select $countries;
run;
You have two different problems in your code:
The quote marks in your datalines section are becoming part of the values of the variable, which you probably don't intend. You should remove them, i.e.:
As written, your PROC FORMAT statement is creating a numeric format, Countries. SAS tries to convert the character values to numeric, and you get null values (that repeat, thus the error message). To tell SAS you want a character format, you add a $ prefix to the name (the $ is actually part of the format name). You can also add a TYPE variable to the dataset.
Then your code works:
The fmtlib option and select statement simply tell SAS to print the format (which is helpful for debugging sometimes). They are optional, so this will work:
Test like: