Hi, I have this lookup table (range), which I intend to use as a format for another table (have).
data range;
input low high desc $8.;
cards;
-999999 1 Low
2 3 Medium
4 999999 High
;
run;
data have;
input num;
cards;
-1
0
5
;
run;
I'd also prefer for the low range, to include all values <= 1, and the high range to include all values > 4.
How is this possible?
Here are changes to make, for this to be suitable for creating a format:
data range;
input start end label $8.;
if label='Low' then HLO='L';
else if label='High' then HLO='H';
fmtname='Range';
cards;
-999999 1 Low
2 3 Medium
4 999999 High
;
Then you can create a format using:
proc format cntlin=range;
run;
And you can use the format when processing HAVE, by adding:
format num range.;
A few notes:
You can use LOW and HIGH to represent below and above respectively, as this code demonstrates:
proc format cntlout=temp;
value test
low-1=23
2-5=45
6-high=99;
run;
The dataset temp will show the output.
Here are changes to make, for this to be suitable for creating a format:
data range;
input start end label $8.;
if label='Low' then HLO='L';
else if label='High' then HLO='H';
fmtname='Range';
cards;
-999999 1 Low
2 3 Medium
4 999999 High
;
Then you can create a format using:
proc format cntlin=range;
run;
And you can use the format when processing HAVE, by adding:
format num range.;
A few notes:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.