06-29-2011 09:02 PM
I've been asked to input all of my data as character and use PROC FORMAT with INVALUE to create new vars as numeric. Some of this data has large ranges and I'd like to use, for instance:
'227' - '8165' = _same_
other = .U;
But I'm getting an error message "ERROR: Start is greater than end: -." due to how character vars are sorted by SAS, I believe.
I'd also like to ensure code such as:
'050' - '400' = _same_
other = .U;
doesn't give unexpected results due to the collation issue.
I've seen some info on NUMERIC_COLLATION but think it's only available for PROC SORT.
Any ideas? I think the best solution is to read the data in as numeric - but might have to find a work around.
06-29-2011 09:20 PM
From what I understand you best read the values as numeric. Code like below could help:
227 - 8165 = _same_
other = .U
input TestData gramf32.;
format TestData best32.;
proc print data=test;
06-30-2011 03:06 AM
There is no need to make a informate for you situation.
data temp; input gra $; num_gra=input(gra, ?? best8.); if num_gra lt 227 or num_gra gt 8165 or missing(num_gra) then num_gra=.U; cards; 226 227 500 1000 8165 8165 8166 wioe ; run;
Message was edited by: xia keshan
07-01-2011 11:21 AM
Since the code examples you provide do not generate the error it would be helpful to either post the whole PROC FORMAT code or the section that is creating the error.
What would be examples of unexpected results?