- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-25-2022 04:16 PM
(786 views)
Hi,
When referencing a character format name, is the $ required?
Example:
proc format lib=formtlib;
value jobfmt 'M' = 'Manager'
'E' = 'Employeed';
run;
If trying to associate the jobfmt with a variable in a format statement:
format jobtitle $jobfmt.;
is the $ required for jobfmt or optional?
Thanks
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It would be a lot quicker to test for yourself. You won't be able to create the SAS format in the first place if you don't put a dollar sign in the name:
28 proc format; 29 value sexfmt 30 'F'='Female' ERROR: The quoted string 'F' is not acceptable to a numeric format or informat. 31 'M'='Male' 32 ; NOTE: The previous statement has been deleted. 33 run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi SASKiwi again!
Yes, it would be quicker just to test it but I won't have access to SAS until tomorrow.
I know when assigning the format-name in the VALUE statement, you need $ for the format-name for character values. My question was, is the $ needed when you reference that format-name.
In your example, when I reference sexfmt in a format statement:
format sex $sexfmt.;
I wanted to know in that format statement, if the $ is optional or required.
Thanks again for helping me with all of my questions!
Yes, it would be quicker just to test it but I won't have access to SAS until tomorrow.
I know when assigning the format-name in the VALUE statement, you need $ for the format-name for character values. My question was, is the $ needed when you reference that format-name.
In your example, when I reference sexfmt in a format statement:
format sex $sexfmt.;
I wanted to know in that format statement, if the $ is optional or required.
Thanks again for helping me with all of my questions!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This is the error you get if you drop the dollar sign from the format:
35 proc print data=sashelp.class; 36 format sex sexfmt.; ERROR: You are trying to use the numeric format SEXFMT with the character variable Sex in data set SASHELP.CLASS. 37 run;