<?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: Proc Format using &amp;quot;Cntlin&amp;quot;, What I am doing wrong!! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918672#M361872</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350312"&gt;@SASuserlot&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;"Testn" variable in "format_from"is numeric. Please correct me if I misunderstood your statement. I am simply trying to create the numeric format from "format_from" using "testn" varaible, and apply that numeric format wherever I need.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your PROC FORMAT code is trying to create a NUMERIC FORMAT.&lt;/P&gt;
&lt;P&gt;Your later code is trying to use a NUMERIC INFORMAT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Formats convert values to text.&amp;nbsp; Informats convert text to values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to convert strings to numbers you have to define an INFORMAT, not a FORMAT.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set the TYPE variable in your CNTLIN dataset to I (for informat).&amp;nbsp; And don't DROP the TYPE variable from the CNTLIN dataset when writing it!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data format_from;
  input test :$3. testn;
cards;
ALT 1
UR 2
KG 3
;

data have;
  input test :$3.;
cards;
ALT
UR
KG
MG
;

data work.outfmtn;
  fmtname='MYINFORMAT';
  type = 'I';
  set work.format_from;
  rename test=start testn=label;  
run;

proc sort data=outfmtn nodupkey;
  by fmtname start;
run;

proc format library=work cntlin=work.outfmtn fmtlib;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 02 Mar 2024 00:22:14 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-03-02T00:22:14Z</dc:date>
    <item>
      <title>Proc Format using "Cntlin", What I am doing wrong!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918658#M361864</link>
      <description>&lt;P&gt;I want to create a numeric format for a character variable ( create a new numeric variable based on character data) using proc format 'Cntlin', I am doing something wrong. I tried a couple of things, but I am ending up format error in the log, or it just creating character to character.&amp;nbsp; What is the easy way to create numeric variable using proc formats.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data format_from;
 test ='ALT';
 testn =1;
 output;
 test ='UR';
 testn =2;
 output;
 test ='KG';
 testn =3;
output;
run;

data have;
 test ='ALT';
 output;
 test ='UR';
 output;
 test ='KG';
output;
 test ='MG';
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;attempt1 :&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data work.outfmtn(keep=start label fmtname); 
    set work.format_from(rename=(test= start  testn=  label));  
    fmtname='Num';
	type = 'N';
run;

proc sort data=outfmtn nodupkey;
    by fmtname start;
run;

proc format library=work cntlin=work.outfmtn;
quit;

data want;
set have;
numeric_test = input(test,num.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Log error:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;777
778
779  data work.outfmtn(keep=start label fmtname);
780      set work.format_from(rename=(test= start  testn=  label));
781      fmtname='Num';
782      type = 'N';
783  run;

NOTE: There were 3 observations read from the data set WORK.FORMAT_FROM.
NOTE: The data set WORK.OUTFMTN has 3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


784
785  proc sort data=outfmtn nodupkey;
786      by fmtname start;
787  run;

NOTE: There were 3 observations read from the data set WORK.OUTFMTN.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.OUTFMTN has 3 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds


788
789  proc format library=work cntlin=work.outfmtn;
&lt;FONT color="#FF0000"&gt;ERROR: For format NUM, this range is repeated, or values overlap: .-..&lt;/FONT&gt;
790  quit;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 3 observations read from the data set WORK.OUTFMTN.
NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

791


792  data want;
793  set have;
794  numeric_test = input(test,num.);
                               ----
                               48
&lt;FONT color="#FF0000"&gt;ERROR 48-59: The informat NUM was not found or could not be loaded.&lt;/FONT&gt;

795  run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WANT may be incomplete.  When this step was stopped there were 0 observations and
         2 variables.
WARNING: Data set WORK.WANT was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Attempt2 : it converting to character variable also creating&amp;nbsp; extra text for not assigned number ( Example : for test ='MG' numeric_test = 'M'. so I can not use 'input' to create numeric.)&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data work.outfmtn(keep=start label fmtname); 
    set work.format_from(rename=(test= start  testn=  label));  
    fmtname='$Num';
	type = 'N';
run;

proc sort data=outfmtn nodupkey;
    by fmtname start;
run;

proc format library=work cntlin=work.outfmtn;
quit;

data want;
set have;
numeric_test = put(test,$num.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1709329258448.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94316i7E9EB546052D92C5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1709329258448.png" alt="SASuserlot_0-1709329258448.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;How I want: ( This is an example, I have like 250 tests associated with numeric)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_1-1709329404836.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94317iCAEB776A6BC26B29/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_1-1709329404836.png" alt="SASuserlot_1-1709329404836.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thank you for your time, suggestions and inputs.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 21:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918658#M361864</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2024-03-01T21:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format using "Cntlin", What I am doing wrong!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918661#M361866</link>
      <description>&lt;P&gt;You try to create a numeric format, but all your start values are character. A numeric format needs numeric values in start, character values there result in missing numeric values.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 22:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918661#M361866</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-03-01T22:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format using "Cntlin", What I am doing wrong!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918666#M361869</link>
      <description>&lt;P&gt;"Testn" variable in "format_from"is numeric. Please correct me if I misunderstood your statement. I am simply trying to create the numeric format from "format_from" using "testn" varaible, and apply that numeric format wherever I need.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 23:08:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918666#M361869</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2024-03-01T23:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format using "Cntlin", What I am doing wrong!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918671#M361871</link>
      <description>&lt;P&gt;This to get the START correct for a numeric format:&lt;/P&gt;
&lt;PRE&gt;data work.outfmtn(keep=start label fmtname); 
    set work.format_from(rename=(testn= start  test=  label));  
    fmtname='Num';
	type = 'N';
run;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Mar 2024 00:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918671#M361871</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-02T00:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format using "Cntlin", What I am doing wrong!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918672#M361872</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350312"&gt;@SASuserlot&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;"Testn" variable in "format_from"is numeric. Please correct me if I misunderstood your statement. I am simply trying to create the numeric format from "format_from" using "testn" varaible, and apply that numeric format wherever I need.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your PROC FORMAT code is trying to create a NUMERIC FORMAT.&lt;/P&gt;
&lt;P&gt;Your later code is trying to use a NUMERIC INFORMAT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Formats convert values to text.&amp;nbsp; Informats convert text to values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to convert strings to numbers you have to define an INFORMAT, not a FORMAT.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set the TYPE variable in your CNTLIN dataset to I (for informat).&amp;nbsp; And don't DROP the TYPE variable from the CNTLIN dataset when writing it!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data format_from;
  input test :$3. testn;
cards;
ALT 1
UR 2
KG 3
;

data have;
  input test :$3.;
cards;
ALT
UR
KG
MG
;

data work.outfmtn;
  fmtname='MYINFORMAT';
  type = 'I';
  set work.format_from;
  rename test=start testn=label;  
run;

proc sort data=outfmtn nodupkey;
  by fmtname start;
run;

proc format library=work cntlin=work.outfmtn fmtlib;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2024 00:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918672#M361872</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-02T00:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format using "Cntlin", What I am doing wrong!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918674#M361874</link>
      <description>&lt;P&gt;With a numeric&amp;nbsp;&lt;U&gt;format&lt;/U&gt;, START has to be numeric. For creating an&amp;nbsp;&lt;U&gt;informat&lt;/U&gt;, LABEL has to be numeric, but in this case, you must also set TYPE to "I" in the CNTLIN dataset and keep it for PROC FORMAT.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2024 07:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918674#M361874</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-03-02T07:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format using "Cntlin", What I am doing wrong!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918836#M361928</link>
      <description>&lt;P&gt;Thank you, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Tom. It worked for my requirements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; for your suggestions and solutions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate all of you guys.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 15:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-using-quot-Cntlin-quot-What-I-am-doing-wrong/m-p/918836#M361928</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2024-03-04T15:01:18Z</dc:date>
    </item>
  </channel>
</rss>

