BookmarkSubscribeRSS Feed
Kc2
Quartz | Level 8 Kc2
Quartz | Level 8

Hello,

 

I am creating a mock shell that has: test code, significance, the grade and the ranges.

The problems I am running into is that the range depends on the test code, the significance and the grade.

I am able to populate the shells with the test code, the significance and the grade but I am  not able to add the ranges I am 4th column

 

Any suggestions?


proc format;

value testcd
1="AAA"
2="BBB"
3="CCC"
;

value sign
1= "Normal"
2= "Abnormal"
;

value grade
1= "GRADE 0"
2= "GRADE 1"
3= "GRADE 2"
4= "GRADE 3"
5= "GRADE 4"
;

invalue $rng
"nAAA0"= "<= ULN"
"nAAA1"= ">ULN - 3x ULN (G1)"
"nAAA2"= ">3x - 5x ULN (G2)"
"nAAA3"= ">5x - 20x ULN (G3)"
"nAAA4"= ">20x ULN (G4)"

"abAAA0"= "<1.5x Baseline"
"abAAA1"= ">1.5x - 3x Baseline (G1)"
"abAAA2"= ">3x - 5x Baseline (G2)"
"abAAA3"= ">5x - 20x Baseline (G3)"
"abAAA4"= ">20x Baseline (G4)"

"nBBB0"="<= ULN"
"nBBB1"=">ULN - 3x ULN (G1)"
"nBBB2"=">3x - 5x ULN (G2)"
"nBBB3"=">5x - 20x ULN (G3)"
"nBBB4"=">20x ULN (G4)"

"abBBB0"= "<1.5x Baseline"
"abBBB1"= ">1.5x - 3x Baseline (G1)"
"abBBB2"= ">3x - 5x Baseline (G2)"
"abBBB3"= ">5x - 20x Baseline (G3)"
"abBBB4"= ">20x Baseline (G4)"

"nCCC0"= "<=ULN"
"nCCC1"= ">ULN - 2.5x ULN (G1)"
"nCCC2"= ">2.5x - 5x ULN (G2)"
"nCCC3"= ">5x - 20x ULN (G3)"
"nCCC4"= ">20x ULN (G4)"

"abCCC0"= "<2x Baseline"
"abCCC1"= ">2x - 2.5x Baseline (G1)"
"abCCC2"= ">2.5x - 5x Baseline (G2)"
"abCCC3"= ">5x - 20x Baseline (G3)"
"abCCC4"= ">20x Baseline (G4)"
;

 

run;

%*---CREATING TABLE SHELL------;

data cat;
length c1 $50;
do ord1=1 to 3 ;
c1=put(ord1,testcd.);
output;
end;
run;

data subcat;
length c1 c2 c3 $50;
do ord= 1 to 3;
c1=put(ord,testcd.);

do ord2= 1 to 2;
c2=put(ord2,sign.);
do ord3= 1 to 5;
c3=put(ord3,grade.);
output;
end;
end;
end;
run;

data shell ;
set cat subcat;
by ord;
run;

Kc2_0-1670615377530.png

 

4 REPLIES 4
ballardw
Super User

What is the purpose of this "shell"?

 

I think you need to clarify exactly what you mean by " I am not able to add the ranges I am 4th column". The "4th column" that I see has a column heading in your picture of C2 and has values.

 

You do not show anything that has a value similar to "nAAA0" to apply the format $rng to or any description of how the other values shown might relate to "nAAA0". If we are supposed to be use the other values shown to derive a "nAAA0" you need to tell us how that might be done.

 

Suggestion: start with fewer values in each piece so the output is small enough to see/discuss easily and make a result that you want manually.

 

If the goal is to have a table with all the formatted values listed with all the others then perhaps this will help. The option on Proc Format of Cntlout creates a data set describing the formats and informats in the format catalog. The Proc Sql selects each format's values and combines them all. If you want the value of the value that the informat/format uses follow the pattern but add requests for a.start as col1 and similar for each set. Note the the values of the START variable will be character. So if you need them as numeric you will have to use an appropriate Input function call for that set of values.

Note: this has serious problems to attempt with any actual range of values instead of one-to-one like your example.

proc format cntlout=work.fmts;

value testcd
1="AAA"
2="BBB"
3="CCC"
;

value sign
1= "Normal"
2= "Abnormal"
;

value grade
1= "GRADE 0"
2= "GRADE 1"
3= "GRADE 2"
4= "GRADE 3"
5= "GRADE 4"
;

invalue $rng
"nAAA0"= "<= ULN"
"nAAA1"= ">ULN - 3x ULN (G1)"
"nAAA2"= ">3x - 5x ULN (G2)"
"nAAA3"= ">5x - 20x ULN (G3)"
"nAAA4"= ">20x ULN (G4)"

"abAAA0"= "<1.5x Baseline"
"abAAA1"= ">1.5x - 3x Baseline (G1)"
"abAAA2"= ">3x - 5x Baseline (G2)"
"abAAA3"= ">5x - 20x Baseline (G3)"
"abAAA4"= ">20x Baseline (G4)"

"nBBB0"="<= ULN"
"nBBB1"=">ULN - 3x ULN (G1)"
"nBBB2"=">3x - 5x ULN (G2)"
"nBBB3"=">5x - 20x ULN (G3)"
"nBBB4"=">20x ULN (G4)"

"abBBB0"= "<1.5x Baseline"
"abBBB1"= ">1.5x - 3x Baseline (G1)"
"abBBB2"= ">3x - 5x Baseline (G2)"
"abBBB3"= ">5x - 20x Baseline (G3)"
"abBBB4"= ">20x Baseline (G4)"

"nCCC0"= "<=ULN"
"nCCC1"= ">ULN - 2.5x ULN (G1)"
"nCCC2"= ">2.5x - 5x ULN (G2)"
"nCCC3"= ">5x - 20x ULN (G3)"
"nCCC4"= ">20x ULN (G4)"

"abCCC0"= "<2x Baseline"
"abCCC1"= ">2x - 2.5x Baseline (G1)"
"abCCC2"= ">2.5x - 5x Baseline (G2)"
"abCCC3"= ">5x - 20x Baseline (G3)"
"abCCC4"= ">20x Baseline (G4)"
;
run;

proc sql;
   create table dummy as
   select a.label as C1,
          b.label as C2,
          c.label as C3,
          d.label as C4
  from (select label from fmts where fmtname='TESTCD') as a,
       (select label from fmts where fmtname='SIGN') as b,
       (select label from fmts where fmtname='GRADE') as c,
       (select label from fmts where fmtname='RNG') as D
  ;
quit;

 

 

Kc2
Quartz | Level 8 Kc2
Quartz | Level 8

I need do do a lab summary table by test, grade and significance. I also need to include the ranges for each grade and each test based on the normal or abnormal value. These ranges are different for each test and the normal/abnormal value. For normal value the ranges are based on ULN and LLN multiplied by a factor x and for abnormal it is based on baseline multiplied by factor x  and x changes with the test.

I was trying to create a mock shell but was having trouble assign the ranges based on the test and the normal/abnormal

 

ballardw
Super User

@Kc2 wrote:

I need do do a lab summary table by test, grade and significance. I also need to include the ranges for each grade and each test based on the normal or abnormal value. These ranges are different for each test and the normal/abnormal value. For normal value the ranges are based on ULN and LLN multiplied by a factor x and for abnormal it is based on baseline multiplied by factor x  and x changes with the test.

I was trying to create a mock shell but was having trouble assign the ranges based on the test and the normal/abnormal

 


Fine, you need to do some analysis with multiple variables. That does not at all describe how this "mock shell" was to be used. Especially since you do not show what a completed "shell" would look like. Which why I suggested reducing the number of levels involved so you might be able to make one manually and share it.

Kc2
Quartz | Level 8 Kc2
Quartz | Level 8

This is how the final shells should look;

Kc2_1-1670770279273.png

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 965 views
  • 0 likes
  • 2 in conversation