BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wlierman
Lapis Lazuli | Level 10

I have a dataset with just under 59K obs.  This data are Medicaid recipients. There are 18 Medicaid CCOs and one open-card designation (these recipients are most likely 'between' membership in a CCO) . The observations are divided between the CCOs on the basis of geographical location within the state. In earlier code a continuity of care measure was created. 

 

I want to create some simple column charts that will group the CCOs together by continuity of care values. The index values range between 0 and 1.  As I envision it I would like the following

 

                                             --------------------- Index_score across the top ---------------------------

                                              1            2        3         4           5           6          7            8           9                     

        CCO by name

       <down the left side>                  <the body of the table would contain the counts of the

                                                           scores - that is, how many recipients in each CCO and the Open-card

                                                           fall into index range 1 through 9 >

 

This is the code so far (using %Let statements to hold whatever index values I want to create a chart)

 

%Let Lb_0 = 0.000;
%Let Lb1 = 0.0001;
%Let Lb2 = 0.2499;
%Let Lb_25 = 0.250;
%Let Lb3 = 0.250001;
%Let Lb4 = 0.4999;
%Let Lb_50 = 0.500;
%Let Lb5 = 0.50001;
%Let Lb6 = 0.7499;
%Let Lb_75 = 0.7500;
%Let Lb7 = 0.750001;
%Let Lb8 = 0.9999;
%Let Lb_1 = 1.000;

 

Data StgCOCxx.CCO_COC_Range (keep = CCO COC_BB_Index indscr);
    Set StgCOCxx.COC_Pmca_complex_Detail_Final;
by CCO;
*retain indscr CCO;
do i = 1 to 9;
  if COC_BB_Index = &Lb_0 then indscr = 1;
  if &Lb1 <= COC_BB_Index <= &Lb2 then indscr=2;
  if COC_BB_Index = &Lb_25 then indscr=3;
  if &Lb3 <= COC_BB_Index <= &Lb4 then indscr=4;
  If COC_BB_Index = &Lb_50 then indscr=5;
  If &Lb5 <= COC_BB_Index <= &Lb6 then indscr=6;
  If COC_BB_Index = &Lb_75 then indscr=7;
  If &Lb7 <= COC_BB_Index <= &Lb8 then indscr=8;
  If COC_BB_Index = &Lb_1 then indscr=9;
end;
run;

 

My abortive attempt on the next data step where I want to create the array

 

Data StgCOCxx.COC_array_index;
  Set StgCOCxx.CCO_COC_Range;        
  array index[*]_numeric_;

 

                .......................

 

I started reading papers on Arrays and ended up restarting a couple of times.  I thoroughly have myself confused.

 

Your help will be greatly appreciated.

 

wlierman

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Do you want a data set or a report? "Across the top" sounds like you want a report that people would read. If so this may help:

Proc format library=work;
value score
0            = 1
0   <-< .25  = 2
.25          = 3
2.5 <-< .5   = 4
.5           = 5
.5  <-< .75  = 6
.75          = 7
.75 <-< 1    = 8
1            = 9
;
run;

proc tabulate data=  StgCOCxx.COC_Pmca_complex_Detail_Final;
   class cco;
   class COC_BB_Index ;
   format COC_BB_Index score.;
   table cco,
         COC_BB_Index*n
   ;
run;

The custom format uses < to indicate an open interval.

 

0 <-< .25 = 2 then says values between 0 and .25 excluding the ends will display a value of 2.

Formats are often an easy way to create interval values that involve single variables and can be used to create groups in almost any procedure.

Add nice labels for CCO and the score variable for nicer table appearance.

An option to go after the main table statement controls what you might like to have appear for missing counts:

   table cco,
         COC_BB_Index*n
         /misstext='0'
   ;

would display a zero for missing counts using the MISSTEXT option. You can place any text you would like though long values make for ugly tables. A blank suppresses the default appearance of . for missing.

 

Note that the comma in the table is a dimension separator

View solution in original post

3 REPLIES 3
SuryaKiran
Meteorite | Level 14

You might not need arrays, try format to map the values and then later you can use proc tabulate or proc report.

 

data have;
input id :$8. val;
datalines;
A 0.001
A 0.001
A 0.002
A 0.003
A 0.004
A 0.001
B 0.002
B 0.004
B 0.005
B 0.001
;
run;

proc format ;
value ind_scr 0.001=1
			  0.002=2
			  0.003=3
			  0.004=4
			  0.005=5
			  other=9;
run;
data want;
set have;
format val ind_scr.;
run;

PROC TABULATE DATA=WORK.WANT;
	CLASS val /	ORDER=UNFORMATTED MISSING;
	CLASS id /	ORDER=UNFORMATTED MISSING;
TABLE id ALL={LABEL="Total"},		/* ROW */
	  val*N="" ALL={LABEL="Total"}*N="";  /* COLUMN*/
RUN;

image.png

Thanks,
Suryakiran
wlierman
Lapis Lazuli | Level 10

SuryaKiran,

 

Your post is a great great way to produce what I am looking for.

 

I appreciate your clarity and quick response.

 

All the best.

 

wlierman

ballardw
Super User

Do you want a data set or a report? "Across the top" sounds like you want a report that people would read. If so this may help:

Proc format library=work;
value score
0            = 1
0   <-< .25  = 2
.25          = 3
2.5 <-< .5   = 4
.5           = 5
.5  <-< .75  = 6
.75          = 7
.75 <-< 1    = 8
1            = 9
;
run;

proc tabulate data=  StgCOCxx.COC_Pmca_complex_Detail_Final;
   class cco;
   class COC_BB_Index ;
   format COC_BB_Index score.;
   table cco,
         COC_BB_Index*n
   ;
run;

The custom format uses < to indicate an open interval.

 

0 <-< .25 = 2 then says values between 0 and .25 excluding the ends will display a value of 2.

Formats are often an easy way to create interval values that involve single variables and can be used to create groups in almost any procedure.

Add nice labels for CCO and the score variable for nicer table appearance.

An option to go after the main table statement controls what you might like to have appear for missing counts:

   table cco,
         COC_BB_Index*n
         /misstext='0'
   ;

would display a zero for missing counts using the MISSTEXT option. You can place any text you would like though long values make for ugly tables. A blank suppresses the default appearance of . for missing.

 

Note that the comma in the table is a dimension separator

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 876 views
  • 0 likes
  • 3 in conversation