<?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 Format/Length in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833770#M329621</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my dataset is like:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 60pt;" border="0" width="80" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD width="80" height="16" style="height: 12.0pt; width: 60pt;"&gt;GKL1 (char)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"10"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"13"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"40"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"16"&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want is:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 60pt;" border="0" width="80" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD width="80" height="16" style="height: 12.0pt; width: 60pt;"&gt;GKL2 (char)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"10"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"13"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" style="height: 12.0pt;"&gt;"40_41"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"16"&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So: Every "40" is to be transformed into "40_41". I tried it with the following Code, but it doesnt work. The problem seems to be the format/length of the new column. Do you have a solution? Thanks! Btw: Ive never understood whats the difference is between format/length and when I have to use which of both.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Eigenges; 
set Eigenges; 
format GKL1 $12.;
gkl2=gkl1; 
if gkl1 in("40" "41") then GKL2="40_41";
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tried it with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Eigenges; 
set Eigenges; 
format GKL2 $12.;
gkl2=gkl1; 
if gkl1 in("40" "41") then GKL2="40_41";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 06:52:57 GMT</pubDate>
    <dc:creator>Konkordanz</dc:creator>
    <dc:date>2022-09-16T06:52:57Z</dc:date>
    <item>
      <title>Format/Length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833770#M329621</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my dataset is like:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 60pt;" border="0" width="80" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD width="80" height="16" style="height: 12.0pt; width: 60pt;"&gt;GKL1 (char)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"10"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"13"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"40"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"16"&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want is:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 60pt;" border="0" width="80" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD width="80" height="16" style="height: 12.0pt; width: 60pt;"&gt;GKL2 (char)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"10"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"13"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" style="height: 12.0pt;"&gt;"40_41"&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.0pt;"&gt;
&lt;TD height="16" align="right" style="height: 12.0pt;"&gt;"16"&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So: Every "40" is to be transformed into "40_41". I tried it with the following Code, but it doesnt work. The problem seems to be the format/length of the new column. Do you have a solution? Thanks! Btw: Ive never understood whats the difference is between format/length and when I have to use which of both.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Eigenges; 
set Eigenges; 
format GKL1 $12.;
gkl2=gkl1; 
if gkl1 in("40" "41") then GKL2="40_41";
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tried it with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Eigenges; 
set Eigenges; 
format GKL2 $12.;
gkl2=gkl1; 
if gkl1 in("40" "41") then GKL2="40_41";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 06:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833770#M329621</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2022-09-16T06:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Format/Length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833773#M329623</link>
      <description>&lt;P&gt;In non-unicode environments Length defines the number of chars you can store in a variable.&lt;/P&gt;
&lt;P&gt;A format just changes the way a value is displayed.&lt;/P&gt;
&lt;P&gt;To solve the problem add&lt;/P&gt;
&lt;P&gt;length GKL $5;&lt;/P&gt;
&lt;P&gt;after set statement.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 07:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833773#M329623</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-09-16T07:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Format/Length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833777#M329625</link>
      <description>&lt;P&gt;Which one do I have to define? The "old" GKL1 or the new one "GKL2"? But regardless: The length-command doesnt change anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: I got the following warning: Length of character variable gkl2 has already been set." Possibe hint for a solution?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data Eigenges; 
set Eigenges; 
length GKL1 $5.;
format GKL1 $12.;
gkl2=gkl1; 
if gkl1 in("40" "41") then GKL2="40_41";
run;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 08:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833777#M329625</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2022-09-16T08:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Format/Length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833778#M329626</link>
      <description>&lt;P&gt;Sorry for the confusion, i meant GKL2.&lt;/P&gt;
&lt;P&gt;You should take part in Programming 1, afaik it is free and you will learn all the basics one must know.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 08:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833778#M329626</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-09-16T08:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Format/Length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833779#M329627</link>
      <description>&lt;P&gt;Programming 1? Whats that?&lt;/P&gt;
&lt;P&gt;Back to my problem: It doesnt work neither with "GKL2". But I get the following warning: "Length of character variable gkl2 has already been set."&lt;/P&gt;
&lt;P&gt;What does that mean? Thank you again for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 08:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833779#M329627</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2022-09-16T08:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Format/Length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833781#M329629</link>
      <description>&lt;P&gt;Programming 1: &lt;A href="https://support.sas.com/edu/schedules.html?ctry=us&amp;amp;crs=PROG1" target="_blank"&gt;https://support.sas.com/edu/schedules.html?ctry=us&amp;amp;crs=PROG1&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the complete log.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;PRE class="lia-code-sample  language-sas"&gt;&lt;CODE&gt;data Eigenges; 
set Eigenges; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I had not noticed, that you are overwriting your initial dataset all the time. This is a bad idea, because now you have to go back to square one and re-create "Eigenges" in its original form. Then please post proc contents of that file, especially the variable definition are required, so that we see what you really have.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 09:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833781#M329629</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-09-16T09:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Format/Length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833784#M329632</link>
      <description>&lt;P&gt;Ah okay, thats an important information for me. It works with a new dataset. So that means: I cant change the length/format, if I refer to the same dataset, right?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 09:21:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833784#M329632</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2022-09-16T09:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Format/Length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833789#M329635</link>
      <description>&lt;P&gt;Since you have made many attempts to get the result you want, each time replacing Eigenges, your data set already contains GKL2.&amp;nbsp; So your task is really to replace the variable, not to create it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Eigenges; 
length GKL2 $ 5;
set Eigenges; 
gkl2=gkl1; 
if gkl1 in("40" "41") then GKL2="40_41";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To replace GKL2:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The format statement will not do it.&amp;nbsp; You need a length statement.&lt;/LI&gt;
&lt;LI&gt;The length statement must come before the set statement.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;(Technically the FORMAT statement could work if you place it before the SET statement.)&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 09:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833789#M329635</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-09-16T09:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Format/Length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833792#M329637</link>
      <description>&lt;P&gt;Great, thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 09:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Length/m-p/833792#M329637</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2022-09-16T09:42:05Z</dc:date>
    </item>
  </channel>
</rss>

