<?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: Turn YYYYMMDD date into Year Qtr yyyyQq in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855854#M42101</link>
    <description>&lt;P&gt;Here is a much better way of doing what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table DATE_TEST as
Select
input(adjudication_dt_id, yymmdd8.) as adjudication_dt format = yyq6.
From SummaryLookup;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Jan 2023 21:37:37 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2023-01-26T21:37:37Z</dc:date>
    <item>
      <title>Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854919#M42048</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have a date formatted as "Numeric" like YYYYMMDD ie 20220927.&amp;nbsp; I would like to convert that to Year and Quarter such as 2022Q3.&amp;nbsp; I'm using a Proc sql statement to hit against another table (SummaryLookup) to bring back the date and need to add a line to create a second field to convert it to yyyyQq please.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;create table DATE_TEST as&lt;BR /&gt;Select&lt;/P&gt;&lt;P&gt;dt_id_YYYYMMDD,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;From SummaryLookup;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 21:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854919#M42048</guid>
      <dc:creator>Cheesiepoof05</dc:creator>
      <dc:date>2023-01-20T21:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854923#M42049</link>
      <description>&lt;P&gt;You only need to change the format of the SAS date variable to &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n02xxe6d9bgflsn18ee7qaachzaw.htm" target="_blank" rel="noopener"&gt;YYQ&lt;/A&gt;&amp;nbsp;with PROC DATASETS.&lt;/P&gt;
&lt;P&gt;Statistical procedures (FREQ, SUMMARY, TABULATE) will use the formatted values to build groups.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 21:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854923#M42049</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-20T21:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854927#M42050</link>
      <description>&lt;P&gt;Thank you but I'm not sure how to put that into my Proc sql; code.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 22:02:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854927#M42050</guid>
      <dc:creator>Cheesiepoof05</dc:creator>
      <dc:date>2023-01-20T22:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854928#M42051</link>
      <description>&lt;P&gt;Please post usable example data (working data steps with datalines) for all datasets used in the join.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 22:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854928#M42051</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-20T22:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854929#M42052</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/434710"&gt;@Cheesiepoof05&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you but I'm not sure how to put that into my Proc sql; code.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You don't have to. Just apply the format when you need it such as in a report or analysis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What result do you see with this code:&lt;/P&gt;
&lt;PRE&gt;proc freq data= SummaryLookup;
   tables dt_id_YYYYMMDD;
   format dt_id_YYYYMMDD yyq6.;
run;
&lt;/PRE&gt;
&lt;P&gt;If your variable is a SAS date value then you should see the values shown in YYYYQN display.&lt;/P&gt;
&lt;P&gt;If not, then you may have to create a new variable.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 22:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854929#M42052</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-20T22:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854930#M42053</link>
      <description>&lt;P&gt;Please provide the report created with code as below so we know what we're dealing with (SAS Date value, just a number or a string). Once we know we can go from there.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Contents data=SummaryLookup(keep=&lt;SPAN&gt;dt_id_YYYYMMDD&lt;/SPAN&gt;);
run;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jan 2023 22:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/854930#M42053</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-01-20T22:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855106#M42059</link>
      <description>&lt;P&gt;This is the code I'm using.&amp;nbsp; It's just hitting against a temporary table where I've already pulled the data from.&amp;nbsp; "adjudication_dt_id" is a "numeric" field with 8 digits.&amp;nbsp; I'm just wanting to create a second field where it takes that numeric field and makes it yyyyQq.&amp;nbsp; So 20220418 in the first field would be 2022Q2 in the second field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;create table DATE_TEST as&lt;BR /&gt;Select&lt;BR /&gt;adjudication_dt_id&lt;/P&gt;&lt;P&gt;From SummaryLookup;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;adjudication_dt_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;20190105&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;20210907&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;20200430&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;20221231&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 23 Jan 2023 15:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855106#M42059</guid>
      <dc:creator>Cheesiepoof05</dc:creator>
      <dc:date>2023-01-23T15:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855119#M42060</link>
      <description>&lt;P&gt;I'd suggest converting the numeric value into a SAS date value&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/ds2pg/n02zpqz4j5u3j9n1t0i95ncqep5g.htm" target="_self"&gt;SAS Date, Time, and Datetime Values&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;Then you can use &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n0c9zxlm4e6m7tn1vrn76c98zw66.htm" target="_self"&gt;SAS date formats&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Better still would be to track back where&amp;nbsp;&lt;SPAN&gt;adjudication_dt_id is created and create/read it as a SAS Date value to start with&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here's an example:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_  ;	
	file "test.txt" ;
	infile cards ;
	input ;
	put _infile_ ;
cards ;
20230123
20221205
20220401
;

data readText ;
	infile "test.txt" ;
	input myDate yymmdd8. ;
	put "no format : " myDate  ;
	put "date7.    : " myDate date7. ;
	put "mmyy.     : " myDate mmyy. ;
	put "yyq.      : " myDate yyq. ;
	put "===========================" ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 16:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855119#M42060</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2023-01-23T16:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855132#M42061</link>
      <description>&lt;P&gt;I got it figured out.&amp;nbsp; I appreciate everyone's time.&amp;nbsp; I went with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;substr(cat(adjudication_dt_id),1,4) as Year,&lt;BR /&gt;substr(cat(adjudication_dt_id),5,2) as Month,&lt;BR /&gt;Case&lt;BR /&gt;WHEN CALCULATED Month = '01' THEN "Q1"&lt;BR /&gt;WHEN CALCULATED Month = '02' THEN "Q1"&lt;BR /&gt;WHEN CALCULATED Month = '03' THEN "Q1"&lt;BR /&gt;WHEN CALCULATED Month = '04' THEN "Q2"&lt;BR /&gt;WHEN CALCULATED Month = '05' THEN "Q2"&lt;BR /&gt;WHEN CALCULATED Month = '06' THEN "Q2"&lt;BR /&gt;WHEN CALCULATED Month = '07' THEN "Q3"&lt;BR /&gt;WHEN CALCULATED Month = '08' THEN "Q3"&lt;BR /&gt;WHEN CALCULATED Month = '09' THEN "Q3"&lt;BR /&gt;WHEN CALCULATED Month = '10' THEN "Q4"&lt;BR /&gt;WHEN CALCULATED Month = '11' THEN "Q4"&lt;BR /&gt;WHEN CALCULATED Month = '12' THEN "Q4"&lt;BR /&gt;ELSE "ERROR"&lt;BR /&gt;END AS Quarter,&lt;BR /&gt;catx('',CALCULATED Year, CALCULATED Quarter) AS YEAR_QTR,&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 16:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855132#M42061</guid>
      <dc:creator>Cheesiepoof05</dc:creator>
      <dc:date>2023-01-23T16:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855145#M42062</link>
      <description>&lt;P&gt;For slightly better, as in "not as long"&lt;/P&gt;
&lt;PRE&gt;Case
WHEN CALCULATED Month in ( '01' '02' '03') THEN "Q1"
WHEN CALCULATED Month in ( '04' '05' '06') THEN "Q2"
WHEN CALCULATED Month in ( '07' '08' '09') THEN "Q3"
WHEN CALCULATED Month in ( '10' '11' '12') THEN "Q4"
ELSE "ERROR"
END AS Quarter,&lt;/PRE&gt;
&lt;P&gt;But in the long run you would be better off turning that not a SAS date value into a SAS date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are multiple functions that allow to do many things with actual dates such as determine intervals between values (how many years/months/quarters/weeks ), see if a date falls on a holiday or which day of the week and many others.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 17:05:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855145#M42062</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-23T17:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855147#M42063</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 17:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855147#M42063</guid>
      <dc:creator>Cheesiepoof05</dc:creator>
      <dc:date>2023-01-23T17:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855176#M42064</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/434710"&gt;@Cheesiepoof05&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I got it figured out.&amp;nbsp; I appreciate everyone's time.&amp;nbsp; I went with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;substr(cat(adjudication_dt_id),1,4) as Year,&lt;BR /&gt;substr(cat(adjudication_dt_id),5,2) as Month,&lt;BR /&gt;Case&lt;BR /&gt;WHEN CALCULATED Month = '01' THEN "Q1"&lt;BR /&gt;WHEN CALCULATED Month = '02' THEN "Q1"&lt;BR /&gt;WHEN CALCULATED Month = '03' THEN "Q1"&lt;BR /&gt;WHEN CALCULATED Month = '04' THEN "Q2"&lt;BR /&gt;WHEN CALCULATED Month = '05' THEN "Q2"&lt;BR /&gt;WHEN CALCULATED Month = '06' THEN "Q2"&lt;BR /&gt;WHEN CALCULATED Month = '07' THEN "Q3"&lt;BR /&gt;WHEN CALCULATED Month = '08' THEN "Q3"&lt;BR /&gt;WHEN CALCULATED Month = '09' THEN "Q3"&lt;BR /&gt;WHEN CALCULATED Month = '10' THEN "Q4"&lt;BR /&gt;WHEN CALCULATED Month = '11' THEN "Q4"&lt;BR /&gt;WHEN CALCULATED Month = '12' THEN "Q4"&lt;BR /&gt;ELSE "ERROR"&lt;BR /&gt;END AS Quarter,&lt;BR /&gt;catx('',CALCULATED Year, CALCULATED Quarter) AS YEAR_QTR,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is a very fine (in fact, textbook) example for stupid data causing stupid code.&lt;/P&gt;
&lt;P&gt;With a proper date value, this mess of WHENs turns into one simple function call. Depending on the following analysis, this whole step might not be necessary at all, as one can always use the proper format to let statistical procedures create the wanted groups.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 19:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855176#M42064</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-23T19:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855846#M42100</link>
      <description>&lt;P&gt;Turning your character date string into a numeric SAS date value with the INPUT function is a much easier option (lot less coding), and then you can apply the YYQw. format to the SAS date value so it displays in the style you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data SummaryLookup;&lt;BR /&gt;input adjudication_dt_id $;&lt;BR /&gt;cards;&lt;BR /&gt;20190105&lt;BR /&gt;20210907&lt;BR /&gt;20200430&lt;BR /&gt;20221231&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table date_test as select &lt;BR /&gt;adjudication_dt_id, input(adjudication_dt_id, yymmdd8.) as new_dt_id format=yyq6.&lt;BR /&gt;from SummaryLookup;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 21:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855846#M42100</guid>
      <dc:creator>jebjur</dc:creator>
      <dc:date>2023-01-26T21:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Turn YYYYMMDD date into Year Qtr yyyyQq</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855854#M42101</link>
      <description>&lt;P&gt;Here is a much better way of doing what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table DATE_TEST as
Select
input(adjudication_dt_id, yymmdd8.) as adjudication_dt format = yyq6.
From SummaryLookup;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jan 2023 21:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Turn-YYYYMMDD-date-into-Year-Qtr-yyyyQq/m-p/855854#M42101</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-01-26T21:37:37Z</dc:date>
    </item>
  </channel>
</rss>

