Hello,
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:
invalue gramf
'227' - '8165' = _same_
other = .U;
run;
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:
invalue weight
'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.
Thank you
From what I understand you best read the values as numeric. Code like below could help:
proc format;
invalue gramf
227 - 8165 = _same_
other = .U
;
run;
data test;
input TestData gramf32.;
format TestData best32.;
datalines;
-40.5
0
226.9
227
500
1000.12345678
8165
8165.1
8166
.
;
run;
proc print data=test;
run;
HTH
Patrick
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;
Ksharp
Message was edited by: xia keshan
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?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.