<?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: Trying to extract year, etc. from numeric/date in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925791#M44699</link>
    <description>&lt;P&gt;Can you show your log?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do have some logical issues, though, what does Yrmth look like and what is the format/type?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Apr 2024 15:17:51 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2024-04-25T15:17:51Z</dc:date>
    <item>
      <title>Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925789#M44698</link>
      <description>&lt;P&gt;I'm trying to do the following extracts. I successfully converted tmonth to date/numeric so it's reading as&lt;BR /&gt;202201, for example. But I am having a hard time extracting year, yr, quarter, inc_mnth and month2 - these are showing blanks&lt;BR /&gt;in the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tab ;
set bat;


format tmonth yyyymm6.;
tmonth=input(put(YrMth,6.),yyyymm6.);

year = year(tmonth);
Quarter = "Q" || put(QTR(tmonth),$1.); 
yr = put (year,z4.); 
inc_mnth = put(year(tmonth),z4.) || put(month(tmonth),z2.);
month2=put(put(month(tmonth),z2.), $mth.);

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Apr 2024 15:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925789#M44698</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-25T15:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925791#M44699</link>
      <description>&lt;P&gt;Can you show your log?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do have some logical issues, though, what does Yrmth look like and what is the format/type?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 15:17:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925791#M44699</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-04-25T15:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925793#M44700</link>
      <description>&lt;P&gt;I you have a valid SAS date variable this could do the job:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;

  /* have */
  d = '25apr2024'd;
  put d= / d= date11.;

  /* want */
  y = year(d);
  m = month(d);

  q_character = put(d, QTR.);
  q_numeric = qtr(d);

  yq = put(d, YYQ.);

  ym_character = put(d, YYMMN.);

  ym_numeric = y*100 + m;

  /* printout*/
  put (_ALL_) (=/);

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 15:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925793#M44700</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-04-25T15:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925795#M44701</link>
      <description>&lt;P&gt;This is the log. I was wrong, it didint "successfully" convert because of the note in the log but it still shows yrmonth&lt;BR /&gt;format. The format type for YrMth was originally CHAR 200 and it looks like 202102.&lt;/P&gt;
&lt;P&gt;(Also , $mth. is just Jan, Feb, mar, etc.)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;83    data tab;
84    set bat;
85    
86    
87    format tmonth yyyymm6.;
                            ---------
                            484
88    tmonth =input(put(YrMth,6.),yyyymm6.);
                                         ---------
                                         485
NOTE 484-185: Format YYYYMM was not found or could not be loaded.
NOTE 485-185: Informat YYYYMM was not found or could not be loaded.
89    
90    year = year(tmonth);
91    Quarter = "Q" || put(QTR(tmonth),$1.);
WARNING: Character format specified for the result of a numeric expression.
92    yr = put (year,z4.);
93    inc_mnth = put(year(tmonth),z4.) || put(month(tmonth),z2.);
94    month2=put(put(month(tmonth),z2.), $mth.);
95    
96    run;
NOTE: Variable YrMth is uninitialized.
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1019039 at 90:8    1019039 at 91:22   1019039 at 93:16   1019039 at 93:49   1019039 at 94:16   
NOTE: There were 1019039 observations read from the data set WORK.bat.
NOTE: The data set WORK.bat has 1019039 observations and 12 variables.
NOTE: Compressing data set WORK.tab decreased size by 41.12 percent. 
      Compressed is 1101 pages; un-compressed would require 1870 pages.
NOTE: DATA statement used (Total process time):
      real time           1.29 seconds
      cpu time            0.99 seconds
      &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 15:43:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925795#M44701</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-25T15:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925796#M44702</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You missed the semicolon...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember SAS stands for "Semicolon, Always Semicolon"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 15:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925796#M44702</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-04-25T15:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925797#M44703</link>
      <description>&lt;P&gt;Did you read your log?&lt;/P&gt;
&lt;P&gt;When I create a single value for Yrmth and attempt some of your code there are immediate problems unless your organization has custom format and informat defined for yyyymmn.&lt;/P&gt;
&lt;P&gt;You don't provided any definition of the $mth. format so can't tell how to "fix" that call&lt;/P&gt;
&lt;PRE&gt;251  data example;
252     yrmth=202404;
253
254     format tmonth yyyymm6.;
                      --------
                      484
255     tmonth=input(put(YrMth,6.),yyyymm6.);
                                   --------
                                   485
NOTE 484-185: Format YYYYMM was not found or could not be loaded.

NOTE 485-185: Informat YYYYMM was not found or could not be loaded.

256
257  run;
&lt;/PRE&gt;
&lt;P&gt;Perhaps this will help:&lt;/P&gt;
&lt;PRE&gt;data example;
   yrmth=202201;

   format tmonth yymm6.;
   tmonth=input(put(YrMth,6.),yymmn6.);
   year = year(tmonth);
   Quarter = "Q" || put(QTR(tmonth),1.); 
   yr = put (year,z4.); 
   inc_mnth = put(tmonth,yymmn6.);
   /*or*/
   inc_month2 = put(yrmth,f6.);
   month2=put(tmonth,monname.);
run;&lt;/PRE&gt;
&lt;P&gt;Note that I am a bit concerned about the rationale for creating all of those character valued "date" bits. Those are generally not as flexible as a numeric date value.&lt;/P&gt;
&lt;P&gt;I used the MONNAME format as a guess for the replacement of the $mth. format not supplied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you may want to be aware that Proc Format with the PICTURE statement will let make your own custom formats so you could do something really useless like display the Year, week, quarter, weekday number and name,&amp;nbsp; month number and name all with one (ugly) format and have some of the "number" type values preceded with 0, blank or nothing leading.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 15:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925797#M44703</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-25T15:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925800#M44704</link>
      <description>I tried yymm6. before and it didn't come through; same with yymmn6.</description>
      <pubDate>Thu, 25 Apr 2024 15:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925800#M44704</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-25T15:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925804#M44706</link>
      <description>&lt;P&gt;Look into this documentation page:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n0c9zxlm4e6m7tn1vrn76c98zw66.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n0c9zxlm4e6m7tn1vrn76c98zw66.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It will help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 15:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925804#M44706</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-04-25T15:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925805#M44707</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290946"&gt;@bhca60&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I tried yymm6. before and it didn't come through; same with yymmn6.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since your example code didn't have a semicolon for the SET statement I have to assume that you had a similar problem with what ever you were trying with the various formats/informats. So the step failed before ever considering them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show YOUR log when you have a question about what the log means when it shows things you don't understand.&lt;/P&gt;
&lt;P&gt;And please do not say "doesn't work" without attaching a log showing it not "not working". The first thing we will ask for is the log to show what is going on.&lt;/P&gt;
&lt;P&gt;Believe it or not, SAS logs are actually helpful. It just takes a bit of experience to understand them.&lt;/P&gt;
&lt;P&gt;And you should always check your log. It is not uncommon for someone to say "something isn't working" because values aren't changing when code is changed. Then we find in error in the code that meant the data set isn't replaced. SAS protects you to some extent by not deleting sets when you have errors.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 15:57:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925805#M44707</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-25T15:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925807#M44708</link>
      <description>&lt;P&gt;the missing semicolon was just copy/paste error.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 16:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925807#M44708</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-25T16:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925808#M44709</link>
      <description>&lt;P&gt;the log didnt say anything more than what is shown in the log I posted.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 16:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925808#M44709</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-25T16:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925809#M44710</link>
      <description>&lt;P&gt;Converting a character string of '202201' to numeric is still not a SAS date value, so you won't be able to extract the year, quarter, etc. A SAS date is the number of days since January 1, 1960. In order to create a true SAS date, you can use the MDY function, along with the SUBSTR and PUT functions to parse out the year and month and convert to numeric, and then add a 'day' value of 1 for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data tab ;&lt;BR /&gt;YrMth='201202';&lt;BR /&gt;tmonth=MDY(put(substr(YrMth,5),2.),1,put(substr(YrMth,1,4),4.)); /* create a numeric SAS date value */&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;year = year(tmonth);&lt;BR /&gt;Quarter = "Q" || put(QTR(tmonth),1.); &lt;BR /&gt;yr = put (year,z4.); &lt;BR /&gt;inc_mnth = put(year(tmonth),z4.) || put(month(tmonth),z2.);&lt;BR /&gt;month2=put(put(month(tmonth),z2.), $mth.);&lt;BR /&gt;format tmonth yymm6.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that help?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 16:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925809#M44710</guid>
      <dc:creator>jebjur</dc:creator>
      <dc:date>2024-04-25T16:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925810#M44711</link>
      <description>Sorry, meant to say along with the SUBSTR and INPUT functions:&lt;BR /&gt;data tab ;&lt;BR /&gt;YrMth='201202';&lt;BR /&gt;tmonth=MDY(input(substr(YrMth,5),2.),1,input(substr(YrMth,1,4),4.));&lt;BR /&gt; year = year(tmonth);&lt;BR /&gt;Quarter = "Q" || put(QTR(tmonth),1.); &lt;BR /&gt;yr = put (year,z4.); &lt;BR /&gt;inc_mnth = put(year(tmonth),z4.) || put(month(tmonth),z2.);&lt;BR /&gt;*month2=put(put(month(tmonth),z2.), $mth.);&lt;BR /&gt;format tmonth yymm6.;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 25 Apr 2024 16:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925810#M44711</guid>
      <dc:creator>jebjur</dc:creator>
      <dc:date>2024-04-25T16:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925812#M44712</link>
      <description>&lt;P&gt;If you mean this log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;83    data tab;
84    set bat;
85    
86    
87    format tmonth yyyymm6.;
                            ---------
                            484
88    tmonth =input(put(YrMth,6.),yyyymm6.);
                                         ---------
                                         485
NOTE 484-185: Format YYYYMM was not found or could not be loaded.
NOTE 485-185: Informat YYYYMM was not found or could not be loaded.
89    
90    year = year(tmonth);
91    Quarter = "Q" || put(QTR(tmonth),$1.);
WARNING: Character format specified for the result of a numeric expression.
92    yr = put (year,z4.);
93    inc_mnth = put(year(tmonth),z4.) || put(month(tmonth),z2.);
94    month2=put(put(month(tmonth),z2.), $mth.);
95    
96    run;
NOTE: Variable YrMth is uninitialized.
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1019039 at 90:8    1019039 at 91:22   1019039 at 93:16   1019039 at 93:49   1019039 at 94:16   
NOTE: There were 1019039 observations read from the data set WORK.bat.
NOTE: The data set WORK.bat has 1019039 observations and 12 variables.
NOTE: Compressing data set WORK.tab decreased size by 41.12 percent. 
      Compressed is 1101 pages; un-compressed would require 1870 pages.
NOTE: DATA statement used (Total process time):
      real time           1.29 seconds
      cpu time            0.99 seconds&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That log shows multiple problems. The biggest is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;NOTE: Variable YrMth is uninitialized.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;That means that there is NEVER a value of YrMth to work with. So everything fails.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1019039 at 90:8    1019039 at 91:22   1019039 at 93:16   1019039 at 93:49   1019039 at 94:16   
NOTE: There were 1019039 observations read from the data set WORK.bat.&lt;/PRE&gt;
&lt;P&gt;See that note about missing values generated? When it says 1019039 at 90:8 that means line 90, or&lt;/P&gt;
&lt;PRE&gt;90    year = year(tmonth);&lt;/PRE&gt;
&lt;P&gt;had a missing result 1019039 times. Since there are 1019039 observations in the data set that means every one of those Year values are missing. And others. Because the data set Work.bat did not have any values of YrMth.&lt;/P&gt;
&lt;P&gt;So you apparently need to fix Work.BAT before attempting this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It also shows use of formats and informats that do not exist: YYYYMM or YYYYMMN are not provided by SAS. All of those format and informats use 2 Y's not 4. YYMM or YYMMN.&lt;/P&gt;
&lt;P&gt;Use a non-existing Informat an the result in SAS guessing an appropriate format and for numbers that usually means a best. So Tmonth would not be a date value but would look exactly like Yrmth (if a value was provided). Because of the format you attempted to use, if it didn't exist, you might think that it "worked" because 202201 would still look like 202201, but not a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 16:28:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925812#M44712</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-25T16:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925818#M44713</link>
      <description>&lt;P&gt;THANK YOU!!!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 16:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925818#M44713</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-25T16:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925821#M44714</link>
      <description>&lt;P&gt;Way too much work on the tmonth (as long as the first day of the month is acceptable)&lt;/P&gt;
&lt;PRE&gt;tmonth=input(YrMth,yymmn6.);&lt;/PRE&gt;
&lt;P&gt;if the Yrmth is character, which is not what the OP said at the start of this.&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/138071"&gt;@jebjur&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Converting a character string of '202201' to numeric is still not a SAS date value, so you won't be able to extract the year, quarter, etc. A SAS date is the number of days since January 1, 1960. In order to create a true SAS date, you can use the MDY function, along with the SUBSTR and PUT functions to parse out the year and month and convert to numeric, and then add a 'day' value of 1 for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data tab ;&lt;BR /&gt;YrMth='201202';&lt;BR /&gt;tmonth=MDY(put(substr(YrMth,5),2.),1,put(substr(YrMth,1,4),4.)); /* create a numeric SAS date value */&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;year = year(tmonth);&lt;BR /&gt;Quarter = "Q" || put(QTR(tmonth),1.); &lt;BR /&gt;yr = put (year,z4.); &lt;BR /&gt;inc_mnth = put(year(tmonth),z4.) || put(month(tmonth),z2.);&lt;BR /&gt;month2=put(put(month(tmonth),z2.), $mth.);&lt;BR /&gt;format tmonth yymm6.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that help?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 16:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925821#M44714</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-25T16:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract year, etc. from numeric/date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925865#M44715</link>
      <description>It was mentioned that YrMth was originallly CHAR 200 in reply to Reeza.</description>
      <pubDate>Thu, 25 Apr 2024 18:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-extract-year-etc-from-numeric-date/m-p/925865#M44715</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-25T18:49:57Z</dc:date>
    </item>
  </channel>
</rss>

