12-13-2016 12:10 AM - last edited on 12-13-2016 03:09 AM by KurtBremser
I defined a format using proc format, and then try to use it in proc sql, but an error message keeps coming out and I don't know what I did wrong. Hope someone can help me with it, thanks a lot!
17 proc format library=Project;
18 value $ range
19 810-high = '810+'
20 790-809 = '790-809'
21 770-789 = '770-789'
22 750-769 = '750-769'
23 730-749 = '730-749'
24 710-729 = '710-729'
25 690-709 = '690-709'
26 670-689 = '670-689'
27 650-669 = '650-669'
28 630-649 = '630-649'
29 low-629 = '<630'
30 other = 'Null or Zero';
32 OPTIONS FMTSEARCH=(Project);
35 proc sql;
36 create table project.n1 as
37 select score, put(Score,$range.) as range
The message is like:
error: character format $range in PUT function requires a character argument.
12-13-2016 12:24 AM
Thanks for replying, I did what you said but it returned another message like ERROR: The format $RANGE was not found or could not be loaded. I did remove the dollar sign from value statement.
12-13-2016 02:16 AM - edited 12-13-2016 02:16 AM
In your sql code you used the format in "put(Score,$range.) as range"
What type is the score variable ? If sas asks for $format it means that the variable is a alphanumeric,
then use: put(input(score, best 5.),range.) as range and remove the $ from the value statment .
12-13-2016 03:08 AM - edited 12-13-2016 03:09 AM
It worked after all, thanks. But the problem is the format 'range' has to be a character format according to the requirement, so I wonder if there is a way to do it?
The result of the put() function is always of type character.
To really illustrate your issue, you need to supply example data; do so in a data step.