I have clams data with diagnosis column DX1 to DX15 which stores ICD9 codes.
I want to create a categorical combined variable (Premature here) where DxLabel is category and icd9 is the corresponding code.
Such pairs could be different each time, may be 4 once, may be 40 next time. Hence I want to be able to only modify two arrays and get the categories situated in one column-(here Premature)
Following code does not work and can someone help me fix it?
%let ColName = Premature;
data RSLTTBL; /* This is the name of result table */
set PLYGRND.kid_2006; /* Copy table from this table */
array diagcol(*) DX1-DX15; /* Define arrary of Diagnosis columns */
array icd9(4) _TEMPORARY_ (76520 76521 76522 76523);
array Dxlabel(4) Unspecified LessthanGA24 GA24 GA2526;
length &ColName $10; /* Define new variable */
&ColName="None"; /*Assign Value to new variable*/
do i=1 to dim(icd9);
if whichn(icd9[i],of diagcol(*))>0 then &ColName=Dxlabel[i]; /*Assign Value to new variable ---I think the problem is here.*/
end;
drop i;
run;
proc freq data=rslttbl;
tables Premature;
run;
The DxLabel array contains 4 numeric variables named Unspecified LessthanGA24 GA24 and GA2526. Perhaps you meant to define a temporary array with the elements "Unspecified" "LessthanGA24" "GA24" and "GA2526". (If that's the case, a length of $10 for &ColName might not be long enough.)
At any rate, it's all a guess. You would need to describe what "does not work" actually means to get a more specific answer.
Thanks for reply label(DxLabel[i]) solved the issue. Thanks anyway
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.