Hi ~ I'm learning the PROC FORMAT CNTLIN part, but have some troubles if the data having multiple labels ...
For example :
IF Code 101,102,103 are classified as A disease ; code 101 ,105 are classified as B disease
If the data sets are as followed
ID CODE
1 101
2 102
3 103
4 105
and wish after using proc format with CNTLIN function ;
the data set would be turned into
ID CODE Classifications
1 101 A
1 101 B
2 102 A
3 103 A
4 105 B
---
DATA test ;
INPUT ID 1 CODE $5-7;
datalines;
1 101
2 102
3 103
4 105
;
run;
DATA NAME;
INPUT CODE $1-3 DZ $5;
datalines;
101 A
102 A
103 A
101 B
105 B
;
run;
DATA fmttest;
set name;
rename code=start dz=label;
retain fmtname "$dz" ;
HLO="M";
run;
PROC FORMAT CNTLIN=fmttest;run;
data test2;
set test;
dz=put(code,$dz.);
run;
but it seems not work at all .. is it possible to use PROC FORMAT with CNTLIN with multiple label function in this way ?
Thanks a lot
I think you need to add the TYPE variable to your CNTLIN dataset since you are defining an character format instead of a numeric format.
Also the $ is not included in the value of FMTNAME.
Also sort the data by FTMNAME and START.
To see the data structure needed you should create a format using proc format and generate the CNTLOUT dataset and check how it looks.
You can leave off TYPE variable and use $ in the name as the OP did. For INFORMAT it would be @$DZ.
I don't think you can get what you want with a format, since it won't expand the data to have multiple records.
You can with a SQL join though.
Using format with the put function is not a multi label application. Aggregation procedures such as means and tabulate are.
There is the multi label option with SAS Base SAS(R) 9.3 Procedures Guide, Second Edition
It is logical a doubled classification of the same variable values, avoiding the need for duplicated runs on the same data.
As the format originally is designed to recode one input to a single new output value your logical questions you started with does not make sense.
The input code look to be diagnostics that can belong to many diseases. Having many of those diagnostics not knowing the disease you could try to build a prediction model. That is total different logical process. What are you trying to do?
To get a Multi Label Format to "do anything" you need a multi label enabled procedure, Means/summary, tabulate and report are it I think.
Here is example using SUMMARY that counts and uses IDGROUP to show the values of CODE in each grouping.
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 16. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: