<?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: get flag and dates format in sas in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/get-flag-and-dates-format-in-sas/m-p/583775#M14023</link>
    <description>&lt;P&gt;Welcome to the SAS Community Forums.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This post is very unclear.&lt;/P&gt;
&lt;P&gt;Please try and clearly post the following information:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. What data do you have?&lt;/P&gt;
&lt;P&gt;Here are instructions on how to provide sample data as a data step:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. What do you want? Based on the input data post what you expect as output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. What is the logic to get there and what have you tried so far that didn't work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PUT() converts variables so will not create any flags. As your pseudocode indicates, you likely need IF/THEN statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a great, but longer and in depth, reference for dates and times in SAS&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Vague questions will get vague answers and taking some time to clarify your question will help you get faster and relevant answers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286442"&gt;@balukumar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi I have one doubt in sas&lt;BR /&gt;in dataset date format have 08-04-1988&lt;BR /&gt;base on this values I want create date styles and along flag values&lt;BR /&gt;For datetime flag creation if dateandtime have then consider flag 1 else 0&lt;BR /&gt;for date if date have then consider flag 1 else 0&lt;BR /&gt;for time if time have then consider flag 1 else 0&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;DATA DAT;&lt;BR /&gt;X= "08APR1988"D;&lt;BR /&gt;FORMAT X DDMMYYD10.;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;Based on above value I want output like below&lt;/P&gt;
&lt;P&gt;Datetime | Date | Time | DatetimeFlag | DateFlag |TimeFlag&lt;BR /&gt;08APR1988 00:00:00 |08-04-1988 |00:00:00 | 0 |1 |0&lt;/P&gt;
&lt;P&gt;I tried like below&lt;BR /&gt;DATA DUMM;&lt;BR /&gt;SET DAT;&lt;BR /&gt;DT=PUT( X, DDMMYY10.);&lt;BR /&gt;DATEF=PUT( X, date9.);&lt;BR /&gt;DTs=PUT( X, DATETIME32.);&lt;BR /&gt;TimeF=PUT( X, TIME.);&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;here if donot have time then its takeing default datewith time similar time also&lt;BR /&gt;i want display if time is not available then consider 00:00:00 similar if date not available the date aslo : 1960-01-01&lt;/P&gt;
&lt;P&gt;but above scirpt is not given expeted result ,&lt;BR /&gt;can you please tell me how to wirte sas coding to achive this task.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 25 Aug 2019 17:03:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-08-25T17:03:17Z</dc:date>
    <item>
      <title>get flag and dates format in sas</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-flag-and-dates-format-in-sas/m-p/583681#M14005</link>
      <description>&lt;P&gt;Hi I have one doubt in sas&lt;BR /&gt;in dataset date format have 08-04-1988&lt;BR /&gt;base on this values I want create date styles and along flag values&lt;BR /&gt;For datetime flag creation if dateandtime have then consider flag 1 else 0&lt;BR /&gt;for date if date have then consider flag 1 else 0&lt;BR /&gt;for time if time have then consider flag 1 else 0&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATA DAT;&lt;BR /&gt;X= "08APR1988"D;&lt;BR /&gt;FORMAT X DDMMYYD10.;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;Based on above value I want output like below&lt;/P&gt;&lt;P&gt;Datetime | Date | Time | DatetimeFlag | DateFlag |TimeFlag&lt;BR /&gt;08APR1988 00:00:00 |08-04-1988 |00:00:00 | 0 |1 |0&lt;/P&gt;&lt;P&gt;I tried like below&lt;BR /&gt;DATA DUMM;&lt;BR /&gt;SET DAT;&lt;BR /&gt;DT=PUT( X, DDMMYY10.);&lt;BR /&gt;DATEF=PUT( X, date9.);&lt;BR /&gt;DTs=PUT( X, DATETIME32.);&lt;BR /&gt;TimeF=PUT( X, TIME.);&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;here if donot have time then its takeing default datewith time similar time also&lt;BR /&gt;i want display if time is not available then consider 00:00:00 similar if date not available the date aslo : 1960-01-01&lt;/P&gt;&lt;P&gt;but above scirpt is not given expeted result ,&lt;BR /&gt;can you please tell me how to wirte sas coding to achive this task.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Aug 2019 15:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-flag-and-dates-format-in-sas/m-p/583681#M14005</guid>
      <dc:creator>balukumar</dc:creator>
      <dc:date>2019-08-24T15:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: get flag and dates format in sas</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-flag-and-dates-format-in-sas/m-p/583683#M14006</link>
      <description>&lt;P&gt;You don't seem to understand how dates and times work.&lt;/P&gt;
&lt;P&gt;Dates are numbers of days. Datetime (and time) are numbers of seconds. If you just apply a datetime format to a value that is in days it will end up looking like some time early on the day 01JAN1960 since there are 86,000 seconds in a day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the DATEPART() and TIMEPART() function to extract the number of days or the seconds since midnight from a datetime value.&lt;/P&gt;
&lt;P&gt;You can build a datatime value from a DATE value by using the DHMS() function. It takes 4 arguments,Days, Hours, MInutes, Seconds, but you really only need to give it the DAYS and SECONDS since you can give a number of seconds that is larger than 60.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;7    data test ;
8      date="08APR1988"D;
9      datetime=dhms(date,0,0,0);
10     put 'RAW Values ' (date datetime) (= comma15.);
11     put 'Formatted Values ' date= date9. datetime= datetime20. ;
12   run;

RAW Values date=10,325 datetime=892,080,000
Formatted Values date=08APR1988 datetime=08APR1988:00:00:00
&lt;/PRE&gt;
&lt;PRE&gt;13   data test ;
14     date="08APR1988"D;
15     datetime=dhms(date,0,0,'08:20't);
16     put 'RAW Values ' (date datetime) (= comma15.);
17     put 'Formatted Values ' date= date9. datetime= datetime20. ;
18   run;

RAW Values date=10,325 datetime=892,110,000
Formatted Values date=08APR1988 datetime=08APR1988:08:20:00
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Aug 2019 16:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-flag-and-dates-format-in-sas/m-p/583683#M14006</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-24T16:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: get flag and dates format in sas</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-flag-and-dates-format-in-sas/m-p/583688#M14008</link>
      <description>&lt;P&gt;What is your actual input?&amp;nbsp; The trivial example input you show just has the one DATE value.&amp;nbsp; So by definition it does not (could not) have any time component.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you starting with a string that you want to convert into date, time and datetime values?&lt;/P&gt;</description>
      <pubDate>Sat, 24 Aug 2019 17:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-flag-and-dates-format-in-sas/m-p/583688#M14008</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-24T17:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: get flag and dates format in sas</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-flag-and-dates-format-in-sas/m-p/583775#M14023</link>
      <description>&lt;P&gt;Welcome to the SAS Community Forums.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This post is very unclear.&lt;/P&gt;
&lt;P&gt;Please try and clearly post the following information:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. What data do you have?&lt;/P&gt;
&lt;P&gt;Here are instructions on how to provide sample data as a data step:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. What do you want? Based on the input data post what you expect as output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. What is the logic to get there and what have you tried so far that didn't work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PUT() converts variables so will not create any flags. As your pseudocode indicates, you likely need IF/THEN statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a great, but longer and in depth, reference for dates and times in SAS&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Vague questions will get vague answers and taking some time to clarify your question will help you get faster and relevant answers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286442"&gt;@balukumar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi I have one doubt in sas&lt;BR /&gt;in dataset date format have 08-04-1988&lt;BR /&gt;base on this values I want create date styles and along flag values&lt;BR /&gt;For datetime flag creation if dateandtime have then consider flag 1 else 0&lt;BR /&gt;for date if date have then consider flag 1 else 0&lt;BR /&gt;for time if time have then consider flag 1 else 0&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;DATA DAT;&lt;BR /&gt;X= "08APR1988"D;&lt;BR /&gt;FORMAT X DDMMYYD10.;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;Based on above value I want output like below&lt;/P&gt;
&lt;P&gt;Datetime | Date | Time | DatetimeFlag | DateFlag |TimeFlag&lt;BR /&gt;08APR1988 00:00:00 |08-04-1988 |00:00:00 | 0 |1 |0&lt;/P&gt;
&lt;P&gt;I tried like below&lt;BR /&gt;DATA DUMM;&lt;BR /&gt;SET DAT;&lt;BR /&gt;DT=PUT( X, DDMMYY10.);&lt;BR /&gt;DATEF=PUT( X, date9.);&lt;BR /&gt;DTs=PUT( X, DATETIME32.);&lt;BR /&gt;TimeF=PUT( X, TIME.);&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;here if donot have time then its takeing default datewith time similar time also&lt;BR /&gt;i want display if time is not available then consider 00:00:00 similar if date not available the date aslo : 1960-01-01&lt;/P&gt;
&lt;P&gt;but above scirpt is not given expeted result ,&lt;BR /&gt;can you please tell me how to wirte sas coding to achive this task.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Aug 2019 17:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-flag-and-dates-format-in-sas/m-p/583775#M14023</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-25T17:03:17Z</dc:date>
    </item>
  </channel>
</rss>

