Hi,
I have the following code below but the formatting in the results table does not band correctly for the first variable, 'money_limit' but does band correctly in the results table for the second variable, 'COST' - can someone please edit my code so that the results table correctly bands the results for both variables, similar to an example below? Thanks.
Currently, it looks something like this:
data money_analysis;
set rd.accounts;
run;
data money_split;
do x=1 to 1000;
money_limit=rand('uniform');
output;
end;
do x=1 to 100;
credit_limit=0;
output;
end;
run;
proc format library=work;
value overunder
0 = 'money_limit = 0'
low -< 0 = 'money_limit < 0'
0 <- high = 'money_limit > 0' ;
run;
data PD_C_12_split;
do x=1 to 1000;
COST=rand('uniform');
output;
end;
do x=1 to 100;
COST=0;
output;
end;
run;
proc format library=work;
value overunder
0 = 'COST = 0'
low -< 0 = 'COST < 0'
0 <-< 1 = '0 < COST < 1'
1 = 'COST = 1' ;
run;
proc freq data=money_analysis;
tables COST*money_limit / nocum norow nocol out=want;
format money_limit overunder.;
format COST overunder.;
run;
You really need to provide some of YOUR data that does not "band" correctly so we can see what might be going on.
A random generated data set does not tell us what your specific issue is, especially since your example "like this" is not populated with any values
Note that BOTH of your posted formats may have issues because you do not end the value with a semicolon. But the big issue is likely that you gave BOTH of the "formats" the same name. So the second "overunder" format overwrote the first one. Each format needs it's own name if you want different "bands".
data example; do cost = . , -1, 0, .5, 1, 1.5; do money_limit = . , -1, 0, .5, 1, 1.5; output; end; end; run; proc format library=work; value money_limit 0 = 'money_limit = 0' low -< 0 = 'money_limit < 0' 0 <- high = 'money_limit > 0' ; value cost 0 = 'COST = 0' low -< 0 = 'COST < 0' 0 <-< 1 = '0 < COST < 1' 1 = 'COST = 1' ; run; proc freq data=example; tables cost*money_limit / nocum norow nocol out=want; format money_limit overunder.;; format cost cost. money_limit money_limit.; run;
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.