I have created a SAS dataset that has the formats that I want to load.
Some formats have range and some of them have just labels.
The range and just label formats don't load together. How can I create one dataset that has all the formats (range,label,numeric,character,date) and I load them at once.
Please send me a link to any examples.
Example
fmtname,start,end,label,hlo
score,-999,400,Score 1,L
score,401,800,Score 2,
score,801,9999,Score 3,H
product,1,,Product 1,
product,2,,Product 2,
proc sort data=myformats
by fmtname start;
run;
PROC FORMAT CNTLIN=myformats;
RUN;
I dont think it is possible to create the numeric format and character format from the same dataset using proc format CNTLIN option.
You have to create separate datasets for numeric format and character format then use separate proc format CNTLIN option.
data have;
type='N';
fmtname='range';
hlo='L';
start=.;
end=10000;
label='<= 100,000';
output;
type='N';
fmtname='range';
hlo=' ';
start=100001;
end=250000;
label='> 100,000';
output;
type='N';
fmtname='range';
hlo=' ';
start=250001;
end=400000;
label='> 250,000';
output;
type='N';
fmtname='range';
hlo=' ';
start=400001;
end=500000;
label='> 400,000';
output;
type='N';
fmtname='range';
start=500001;
end=.;
hlo='H';
label='> 500,000';
output;
run;
data have2;
/*character format*/
type='C';
fmtname='$sexsg';
start='F';
label='Female';
output;
type='C';
fmtname='$sexsg';
start='M';
label='Male';
output;
run;
proc format cntlin=have fmtlib;
run;
proc format cntlin=have2 fmtlib;
run;
I dont think it is possible to create the numeric format and character format from the same dataset using proc format CNTLIN option.
You have to create separate datasets for numeric format and character format then use separate proc format CNTLIN option.
data have;
type='N';
fmtname='range';
hlo='L';
start=.;
end=10000;
label='<= 100,000';
output;
type='N';
fmtname='range';
hlo=' ';
start=100001;
end=250000;
label='> 100,000';
output;
type='N';
fmtname='range';
hlo=' ';
start=250001;
end=400000;
label='> 250,000';
output;
type='N';
fmtname='range';
hlo=' ';
start=400001;
end=500000;
label='> 400,000';
output;
type='N';
fmtname='range';
start=500001;
end=.;
hlo='H';
label='> 500,000';
output;
run;
data have2;
/*character format*/
type='C';
fmtname='$sexsg';
start='F';
label='Female';
output;
type='C';
fmtname='$sexsg';
start='M';
label='Male';
output;
run;
proc format cntlin=have fmtlib;
run;
proc format cntlin=have2 fmtlib;
run;
Thanks Jag
The value "product" is not a valid name for a char-format, if you don't use the type variable.
Can you please post the datasets "myformats" using datalines, so that we have the same starting point.
Hi Andrea, my apologies. I was only trying to describe as an example and is not the actual data. The example that jag has provided above is exactly what I need in addition to another format that would be numeric with labels and not range.
Also, how does 'type' column help proc statement PROC FORMAT CNTLIN
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.