BookmarkSubscribeRSS Feed
THS
Calcite | Level 5 THS
Calcite | Level 5

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

6 REPLIES 6
Tom
Super User Tom
Super User

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.

data_null__
Jade | Level 19

You can leave off TYPE variable and use $ in the name as the OP did.  For INFORMAT it would be @$DZ.

Reeza
Super User

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.

LinusH
Tourmaline | Level 20

Using format with the put function is not a multi label application.  Aggregation procedures such as means and tabulate are.

Data never sleeps
jakarman
Barite | Level 11

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?      

---->-- ja karman --<-----
data_null__
Jade | Level 19

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.

DATA test ;
INPUT ID CODE $;
datalines;
1 101   
2 102
3 103
4 105
;
run;
proc print;
  
run;
DATA NAME;
INPUT CODE $ DZ $;
datalines;
101 A
102 A
103 A
101 B
105 B
;
run;

DATA fmttest;
   set name;
   rename code=start dz=label;
   retain fmtname "$dz";
  
retain HLO "M";
  
run;

PROC FORMAT CNTLIN=fmttest cntlout=cntlout;
   select $dz;
   run;
proc print;
  
run;

proc summary data=test completetypes nway;
  
class code / preloadfmt mlf;
  
format code $dz.;
  
output out=test2 idgroup(out[4](code)=ocode);
   run;
proc print;
  
format ocode:;
   run;


4-5-2015 5-46-06 AM.png

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 6 replies
  • 1038 views
  • 0 likes
  • 6 in conversation