<?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 modify data in sas eg in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89028#M8353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi..&lt;/P&gt;&lt;P&gt;Try this...hope it helps..you can also modify informat/format according to your requirement.&lt;IMG alt="eg.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/2183_eg.png" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jun 2012 06:39:31 GMT</pubDate>
    <dc:creator>shivas</dc:creator>
    <dc:date>2012-06-22T06:39:31Z</dc:date>
    <item>
      <title>How to modify data in sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89023#M8348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wondering if i can do this in sas eg.&lt;/P&gt;&lt;P&gt;basically i have this data&lt;/P&gt;&lt;P&gt;&lt;IMG alt="screen 2.jpg" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/2172_screen 2.jpg" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i was wondering if there is a way in sas eg so that in coloumn F16 I can put a space between the 'hour' and the 'AM/PM'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, in the first row &lt;/P&gt;&lt;P&gt;it would be like&amp;nbsp; '20/06/2012 10:02:35 AM'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2012 06:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89023#M8348</guid>
      <dc:creator>sugita</dc:creator>
      <dc:date>2012-06-21T06:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify data in sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89024#M8349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can define you own format by using directives in a picture statement as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;&amp;nbsp; picture dmyhmsampm low-high = '%0d/%0m/%Y %0I:%0M:%0S %p' (datatype=datetime);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x = '20Jun2012 10:02:35'dt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put x dmyhmsampm.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For explanation of these directives please see the documentation for PICTURE statement in PROC FORMAT section.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2012 08:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89024#M8349</guid>
      <dc:creator>Alpay</dc:creator>
      <dc:date>2012-06-21T08:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify data in sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89025#M8350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am sorry but i dont understand at all everything that you just said in your post.&lt;/P&gt;&lt;P&gt;Do i filter the data? or query? or what?&lt;/P&gt;&lt;P&gt;I got that data from a csv file that i import to the SAS Data imported just like in the pic.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Untitled.jpg" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/2180_Untitled.jpg" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 05:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89025#M8350</guid>
      <dc:creator>sugita</dc:creator>
      <dc:date>2012-06-22T05:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify data in sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89026#M8351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS assigns a format to a column to display the value stored in that column. &lt;/P&gt;&lt;P&gt;The above code would be used with datetime values which are stored as numeric variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just realized that F16 is a character column not numeric.&lt;/P&gt;&lt;P&gt;In this case, you will need to change the value of that string with an operation or create a new variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NewVar = PRXCHANGE('s/(AM|PM)/ $1/',-1,F16);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x = '20/06/2012 10:02:35AM';&lt;/P&gt;&lt;P&gt;&amp;nbsp; y = PRXCHANGE('s/(AM|PM)/ $1/',-1,x);&lt;/P&gt;&lt;P&gt;&amp;nbsp; put y=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 05:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89026#M8351</guid>
      <dc:creator>Alpay</dc:creator>
      <dc:date>2012-06-22T05:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify data in sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89027#M8352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I still do not understand your post. &lt;/P&gt;&lt;P&gt;Yes the F16 coloumn is stored in string. but where do i write this code?&lt;/P&gt;&lt;P&gt;All I did so far is just import the data from csv and i dont see the option of putting the code. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 06:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89027#M8352</guid>
      <dc:creator>sugita</dc:creator>
      <dc:date>2012-06-22T06:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify data in sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89028#M8353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi..&lt;/P&gt;&lt;P&gt;Try this...hope it helps..you can also modify informat/format according to your requirement.&lt;IMG alt="eg.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/2183_eg.png" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 06:39:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89028#M8353</guid>
      <dc:creator>shivas</dc:creator>
      <dc:date>2012-06-22T06:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify data in sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89029#M8354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Once you get your data set say work.state you can open a program editor window and create another data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;File -&amp;gt; New -&amp;gt; Program&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data work.state2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set work.state;&lt;/P&gt;&lt;P&gt;&amp;nbsp; NewVar = PRXCHANGE('s/(AM|PM)/ $1/',-1,F16);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 07:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89029#M8354</guid>
      <dc:creator>Alpay</dc:creator>
      <dc:date>2012-06-22T07:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify data in sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89030#M8355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No good. I tried to change the format &lt;/P&gt;&lt;P&gt;&lt;IMG alt="Untitled.jpg" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/2184_Untitled.jpg" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and this is what i get&lt;/P&gt;&lt;P&gt;&lt;IMG alt="2.jpg" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/2185_2.jpg" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 07:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89030#M8355</guid>
      <dc:creator>sugita</dc:creator>
      <dc:date>2012-06-22T07:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify data in sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89031#M8356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the query builder, create a query on your dataset. Create a new advanced expression, and in the advanced expression editor, type&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;substr(F16, 1, 19) || ' ' || substr(F16, 20, 2)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 11:45:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89031#M8356</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2012-06-22T11:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify data in sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89032#M8357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What you should do is convert this datetime string in your raw data into a SAS datetime value. The challenge you have is that the way your datetime string looks like is kind of unusual: AM/PM is a US American way of writing a date - but then the datepart of your string is DMY and not MDY. There is no SAS ready made informat to convert such a string into a SAS datetime value (which is a numeric value containing the number of seconds since 1/1/1960).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A 2 step approach is needed: First read the data as string, then use the query builder and in the advanced expression builder convert the string to a form as interpretable by a standard SAS Informat&amp;nbsp; (mmddyyyy hh:mm:ss AM|PM), then read this string using a informat which will convert the string to a SAS datetime value.&lt;/P&gt;&lt;P&gt;You then also need to apply a format to the output variable in order to make the numeric value (the seconds since 1/1/1960) human readable. The format could be "Datetime21."&lt;/P&gt;&lt;P&gt;If you need the formated datetime value to look exactly as you specified it (ddmmyyyyy hh:mm:ss AM|PM) then again there is no standart SAS Format for this. You would need to define your own format using the code Alpay provided (the picture format). You would need to run this code in a code node before you then can use it in the query builder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below the nested function creating a SAS datetime value out of your raw data datetime string - to be used in the query builder advanced expression:&lt;/P&gt;&lt;P&gt;input(prxchange('s/(\d{2}\/)(\d{2}\/)(.*)(AM|PM)/$2$1$3 $4/oi',1,t1.F16),mdyampm25.2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And last but not least:&lt;/P&gt;&lt;P&gt;The huge advantage in converting the string to a SAS datetime value is that you then can use calender functions with it (like intnx(), intck(), datepart()....).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 12:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-modify-data-in-sas-eg/m-p/89032#M8357</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-06-22T12:07:40Z</dc:date>
    </item>
  </channel>
</rss>

