<?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 Extracting first few digits from a class in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-first-few-digits-from-a-class/m-p/735843#M229238</link>
    <description>&lt;PRE&gt;data base1;
set lib.base1;

run;

proc summary data=base1 nway missing;
class prd;
var gp;

run;&lt;/PRE&gt;&lt;P&gt;My prd is a set of date. I am required to extract the first 4 digits of it. For example, 202012, and I only need 2020.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Is there any way to extract it? Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Apr 2021 07:40:17 GMT</pubDate>
    <dc:creator>jiasyuen</dc:creator>
    <dc:date>2021-04-21T07:40:17Z</dc:date>
    <item>
      <title>Extracting first few digits from a class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-first-few-digits-from-a-class/m-p/735843#M229238</link>
      <description>&lt;PRE&gt;data base1;
set lib.base1;

run;

proc summary data=base1 nway missing;
class prd;
var gp;

run;&lt;/PRE&gt;&lt;P&gt;My prd is a set of date. I am required to extract the first 4 digits of it. For example, 202012, and I only need 2020.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Is there any way to extract it? Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 07:40:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-first-few-digits-from-a-class/m-p/735843#M229238</guid>
      <dc:creator>jiasyuen</dc:creator>
      <dc:date>2021-04-21T07:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting first few digits from a class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-first-few-digits-from-a-class/m-p/735851#M229240</link>
      <description>&lt;P&gt;Depends on the type of prd:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;if it is a string, use substr-function&lt;/LI&gt;
&lt;LI&gt;if it is numeric, convert in to string and use substr&lt;/LI&gt;
&lt;LI&gt;if you have a real date, use year-function to extract the year.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 21 Apr 2021 07:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-first-few-digits-from-a-class/m-p/735851#M229240</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-04-21T07:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting first few digits from a class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-first-few-digits-from-a-class/m-p/735857#M229241</link>
      <description>&lt;P&gt;Let say it's a string. How would I convert? Can you show me the line of code? Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 08:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-first-few-digits-from-a-class/m-p/735857#M229241</guid>
      <dc:creator>jiasyuen</dc:creator>
      <dc:date>2021-04-21T08:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting first few digits from a class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-first-few-digits-from-a-class/m-p/735876#M229243</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data base1;
set lib.base1;
prd2=substrn(prd,1,4);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Apr 2021 08:45:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-first-few-digits-from-a-class/m-p/735876#M229243</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-21T08:45:07Z</dc:date>
    </item>
  </channel>
</rss>

