<?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: Regarding BCE and CE dates in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817626#M34557</link>
    <description>&lt;P&gt;Hi Paige,&lt;/P&gt;&lt;P&gt;Thank you so much for your kind support. Brilliant, it works perfectly. Thanks&lt;/P&gt;&lt;P&gt;Here is some data:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Uddin_0-1655003740800.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72153iD32D91CEA8540CA4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Uddin_0-1655003740800.png" alt="Uddin_0-1655003740800.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Jun 2022 03:16:23 GMT</pubDate>
    <dc:creator>Uddin</dc:creator>
    <dc:date>2022-06-12T03:16:23Z</dc:date>
    <item>
      <title>Regarding BCE and CE dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817579#M34550</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am stuck on the above mentioned issue. I have a data set with a variable date only year like 8300 BCE, 1282 CE, Unknown.&lt;U&gt;I want to make it numeric variable with negative values for BCE dates and positive values for CE dates&lt;/U&gt;. I tried to make it with SCAN function, but it comes only numeric value like 8300, 1282, unknown. My question is how I can do it according to my question.&lt;/P&gt;&lt;P&gt;Please find attached a part of the data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking for your kind help&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jun 2022 08:03:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817579#M34550</guid>
      <dc:creator>Uddin</dc:creator>
      <dc:date>2022-06-11T08:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding BCE and CE dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817580#M34551</link>
      <description>&lt;P&gt;Only year ... if there is a text string, such as 'Unknown' or even '1282 CE', these will be read as character strings. There's no way to read them as numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So read them as character strings, and then convert them in a data step, for example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    if find(year,'bce','i')&amp;gt;0 then year1=input(scan(year,1),4.)*-1;
    else if find(year,'ce','i')&amp;gt;0 then year1=input(scan(year,1),4.);
    else year1=.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, this depends on the formatting of your years in the data set, it may be that other coding is needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: I see that you have attached a data set, but I never download files from public forums. You could copy and paste 5 or 10 rows of your .csv file into your message, I would be able to use the data in that case.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jun 2022 10:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817580#M34551</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-11T10:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding BCE and CE dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817608#M34555</link>
      <description>&lt;P&gt;One way reading a few line of text from your attachment:&lt;/P&gt;
&lt;PRE&gt;data example;
   infile datalines truncover;
   input textdate $10.;
   if index(textdate,'BCE')&amp;gt;0 then year= (-1)* input(scan(textdate,1),4.);
   else if index(textdate,'CE')&amp;gt;0 then year=  input(scan(textdate,1),4.);
datalines;
8300 BCE
4040 BCE
Unknown
3600 BCE
1282 CE
104 BCE
Unknown
1538 CE
1944 CE
1302 CE
8040 BCE
2016 CE
Unknown
;&lt;/PRE&gt;
&lt;P&gt;Your use of SCAN was probably correct just did not check for the existence of the string portion of "BCE" to make the values negative. INDEX is one of the functions you can use to check if a string value is part of another character value. It will return the position number of the start of the string if found or 0. SAS will treat non-zero non-missing values as true so works for the logic shown.&lt;/P&gt;
&lt;P&gt;Note the above will leave the "Unknown" as missing values.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jun 2022 18:58:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817608#M34555</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-11T18:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding BCE and CE dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817626#M34557</link>
      <description>&lt;P&gt;Hi Paige,&lt;/P&gt;&lt;P&gt;Thank you so much for your kind support. Brilliant, it works perfectly. Thanks&lt;/P&gt;&lt;P&gt;Here is some data:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Uddin_0-1655003740800.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72153iD32D91CEA8540CA4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Uddin_0-1655003740800.png" alt="Uddin_0-1655003740800.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2022 03:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817626#M34557</guid>
      <dc:creator>Uddin</dc:creator>
      <dc:date>2022-06-12T03:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding BCE and CE dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817627#M34558</link>
      <description>Hi Ballardw,&lt;BR /&gt;Thanks for your kind support. The code is working perfectly. Kind Regards</description>
      <pubDate>Sun, 12 Jun 2022 03:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Regarding-BCE-and-CE-dates/m-p/817627#M34558</guid>
      <dc:creator>Uddin</dc:creator>
      <dc:date>2022-06-12T03:21:20Z</dc:date>
    </item>
  </channel>
</rss>

