<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to make a data-set mixture of Type = 'C' and Type = 'N' and use it as formats. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-data-set-mixture-of-Type-C-and-Type-N-and-use-it/m-p/270103#M53616</link>
    <description>&lt;P&gt;Thanks &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_self"&gt;&lt;SPAN class="login-bold"&gt;ballardw&lt;/SPAN&gt;&lt;/A&gt; for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What codes should I use if&amp;nbsp;I&lt;SPAN&gt;&amp;nbsp;have a different range of numbers that want a different format. &amp;nbsp;For this you can consider the following datalines:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/* Or you can consider any values / datalines as you like - that give me good exposure. */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;datalines;&lt;BR /&gt;020 Plague&lt;BR /&gt;022 Anthrax&lt;BR /&gt;390 500.50&lt;BR /&gt;410 Myocardial infarction&lt;BR /&gt;493 200.50&lt;BR /&gt;540 Appendicitis&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 May 2016 10:35:39 GMT</pubDate>
    <dc:creator>AG_Stats</dc:creator>
    <dc:date>2016-05-13T10:35:39Z</dc:date>
    <item>
      <title>How to make a data-set mixture of Type = 'C' and Type = 'N' and use it as formats.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-data-set-mixture-of-Type-C-and-Type-N-and-use-it/m-p/267676#M52925</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here my concern is how to&amp;nbsp;make a data-set mixture of Type = 'C' and Type = 'N' and use it as formats.&lt;/P&gt;&lt;P&gt;Below are the codes for Character formats and I want a dataset mixture of char and numeric formats.&lt;/P&gt;&lt;P&gt;Please modify the below dataset and codes accordingly. (If it is not possible with below program / codes then please give me some alternate program / codes for the same problem)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname learn '/folders/myfolders/sas';

*-----------------------------------------------------------------------------------*
 Creating a test data set that will be used to make a CNTLIN data set
*-----------------------------------------------------------------------------------*;
data learn.codes;
	input ICD9 : $5. Description &amp;amp; $21.;
datalines;
020 Plague
022 Anthrax
390 Rheumatic fever
410 Myocardial infarction
493 Asthma
540 Appendicitis
;

*----------------------------------------------------------------------*
 Creating a CNTLIN data set from an existing SAS data set
*----------------------------------------------------------------------*;
data control;
	set learn.codes(rename= (ICD9 = Start Description = Label));
	retain Fmtname '$ICDFMT' Type 'C';
run;
title "Demonstrating an Input Control Data Set";
proc format cntlin=control fmtlib;
run;

*------------------------------------------------*
 Using the CNTLIN= created data set
*------------------------------------------------*;
data disease;
	input ICD9 : $5. @@;
datalines;
020 410 500 493
;
title "Listing of DISEASE";
proc print data=disease noobs;
	format ICD9 $ICDFMT.;
run;

*-----------------------------------------------------*
 Adding an OTHER category to your format
*-----------------------------------------------------*;
proc delete data=control;
data control;
	set learn.codes(rename= (ICD9 = Start Description = Label)) end = last;
	
	retain Fmtname '$ICDFMT' Type 'C';
	
	if last then do;
		Start = ' ';
		Hlo = 'o';
		Label = 'Not Found';
	end;
run;

proc format cntlin=control fmtlib;
run; /* Note: Remember to run proc format again */

data disease;
	input ICD9 : $5. @@;
datalines;
020 410 500 493
;
title "Listing of DISEASE";
proc print data=disease noobs;
	format ICD9 $ICDFMT.;
run;


*--------------------------------------------------------------------------*
 Updating an existing format using a CNTLOUT=data set option 
*--------------------------------------------------------------------------*;

proc format cntlout=control_out;
	select $ICDFMT;
run;

data new_control;
	length Label $ 21;
	
	set control_out end=Last;
	output;

	if Last then
		do;
			Hlo=' ';
			
			Start='427.5';
			End=Start;
			Label='Cardiac Arrest';
			output;
			
			Start='466';
			End=Start;
			Label='Bronchitis';
			output;
		end;
run;

proc format cntlin=new_control;
	select $ICDFMT;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 May 2016 17:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-data-set-mixture-of-Type-C-and-Type-N-and-use-it/m-p/267676#M52925</guid>
      <dc:creator>AG_Stats</dc:creator>
      <dc:date>2016-05-02T17:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a data-set mixture of Type = 'C' and Type = 'N' and use it as formats.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-data-set-mixture-of-Type-C-and-Type-N-and-use-it/m-p/267693#M52926</link>
      <description>&lt;P&gt;I'm not quite clear on your objective. Are you attempting to create numeric and character version of the same values? Or do you have a different range of numbers that want a different format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are attempting to create a SINGLE Cntlin data set then when you create format statements you will need to sort the data by the format name before use in proc format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this help?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data codes;
	input ICD9 : $5. Description &amp;amp; $21.;
   start = put (ICD9, z3.);
   label = Description;
   FmtName = '$ICDFMt'; 
   type='C';
   output;
   FmtName = 'ICDFMt'; 
   type='N';
   output;
datalines;
020 Plague
022 Anthrax
390 Rheumatic fever
410 Myocardial infarction
493 Asthma
540 Appendicitis
;
run;

proc sort data=codes;
   by FmtName start;
run;

Proc format library=work cntlin=codes;
run;

data test;
   x=20;
   y='022';
run;

proc print data=test;
   format x Icdfmt. y $Icdfmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 May 2016 18:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-data-set-mixture-of-Type-C-and-Type-N-and-use-it/m-p/267693#M52926</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-02T18:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a data-set mixture of Type = 'C' and Type = 'N' and use it as formats.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-data-set-mixture-of-Type-C-and-Type-N-and-use-it/m-p/270103#M53616</link>
      <description>&lt;P&gt;Thanks &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_self"&gt;&lt;SPAN class="login-bold"&gt;ballardw&lt;/SPAN&gt;&lt;/A&gt; for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What codes should I use if&amp;nbsp;I&lt;SPAN&gt;&amp;nbsp;have a different range of numbers that want a different format. &amp;nbsp;For this you can consider the following datalines:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/* Or you can consider any values / datalines as you like - that give me good exposure. */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;datalines;&lt;BR /&gt;020 Plague&lt;BR /&gt;022 Anthrax&lt;BR /&gt;390 500.50&lt;BR /&gt;410 Myocardial infarction&lt;BR /&gt;493 200.50&lt;BR /&gt;540 Appendicitis&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2016 10:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-data-set-mixture-of-Type-C-and-Type-N-and-use-it/m-p/270103#M53616</guid>
      <dc:creator>AG_Stats</dc:creator>
      <dc:date>2016-05-13T10:35:39Z</dc:date>
    </item>
  </channel>
</rss>

