<?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 Store Date values in variables and concatenate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877964#M346863</link>
    <description>&lt;P&gt;Can you please help me the below requirement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to store date values as below.&lt;/P&gt;
&lt;P&gt;data t1;&lt;/P&gt;
&lt;P&gt;validfrom=&amp;lt;firstdayoflastmonth&amp;gt; e.g 01APR2023;&lt;/P&gt;
&lt;P&gt;ValidTill=&amp;lt;lastdayoflastmonth&amp;gt; e.g 30APR2023;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;already, I have another dataset , where above two variables (validfrom and validtill) have dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to concatenate both of them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used something, but this is storing as character, and unable to concatenate.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let firstdayofthelastmonth = %sysfunc(intnx(month,%sysfunc(today()),-1),date9.);&lt;BR /&gt;%let lastdayofthelastmonth = %sysfunc(intnx(month,%sysfunc(today()),-1,e),date9.);&lt;BR /&gt;%put &amp;amp;firstdayofthelastmonth.;&lt;BR /&gt;%put &amp;amp;lastdayofthelastmonth.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kindly suggest.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 28 May 2023 19:49:00 GMT</pubDate>
    <dc:creator>kumarsandip975</dc:creator>
    <dc:date>2023-05-28T19:49:00Z</dc:date>
    <item>
      <title>Store Date values in variables and concatenate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877964#M346863</link>
      <description>&lt;P&gt;Can you please help me the below requirement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to store date values as below.&lt;/P&gt;
&lt;P&gt;data t1;&lt;/P&gt;
&lt;P&gt;validfrom=&amp;lt;firstdayoflastmonth&amp;gt; e.g 01APR2023;&lt;/P&gt;
&lt;P&gt;ValidTill=&amp;lt;lastdayoflastmonth&amp;gt; e.g 30APR2023;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;already, I have another dataset , where above two variables (validfrom and validtill) have dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to concatenate both of them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used something, but this is storing as character, and unable to concatenate.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let firstdayofthelastmonth = %sysfunc(intnx(month,%sysfunc(today()),-1),date9.);&lt;BR /&gt;%let lastdayofthelastmonth = %sysfunc(intnx(month,%sysfunc(today()),-1,e),date9.);&lt;BR /&gt;%put &amp;amp;firstdayofthelastmonth.;&lt;BR /&gt;%put &amp;amp;lastdayofthelastmonth.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kindly suggest.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2023 19:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877964#M346863</guid>
      <dc:creator>kumarsandip975</dc:creator>
      <dc:date>2023-05-28T19:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Store Date values in variables and concatenate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877965#M346864</link>
      <description>&lt;P&gt;What exactly do you need to concatenate? Please provide an example and be specific.&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2023 19:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877965#M346864</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-05-28T19:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Store Date values in variables and concatenate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877968#M346866</link>
      <description>&lt;P&gt;What do you mean by "concatenate"?&lt;/P&gt;
&lt;P&gt;Concatenation is a character operation, like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want = x !! y;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 May 2023 19:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877968#M346866</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-28T19:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Store Date values in variables and concatenate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877969#M346867</link>
      <description>&lt;P&gt;There is a major disconnect between this statement:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I have another dataset , where above two variables (validfrom and validtill) have dates.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;And your later usage of MACRO CODE.&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let firstdayofthelastmonth = %sysfunc(intnx(month,%sysfunc(today()),-1),date9.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;If you have data in a data step then use SAS CODE to manipulate the data.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So if you want to make new variable that concatenates the values of two dates then you will need to first convert them into STRINGS.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First let's make a dataset with the two date variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  validfrom='01APR2023'd;
  validtill='30APR2023'd;
  format validfrom validtill date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Perhaps by using VVALUE() function so whatever display format you have attached to the variable is used in the conversion?&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length combined $19 ;
  combined=catx('-',vvalue(validfrom),vvalue(validtill));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    validfrom    validtill         combined

 1     01APR2023    30APR2023    01APR2023-30APR2023&lt;/PRE&gt;
&lt;P&gt;But I suspect that your real request is something totally different, so please provide more information about what you are actually trying to do.&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>Sun, 28 May 2023 20:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877969#M346867</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-28T20:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Store Date values in variables and concatenate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877970#M346868</link>
      <description>&lt;P&gt;I'm also not sure what you mean by concatenate, but from the code you shared, I wonder if you're trying to do something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let firstdayofthelastmonth = "%sysfunc(intnx(month,%sysfunc(today()),-1),date9.)"d;
%let lastdayofthelastmonth = "%sysfunc(intnx(month,%sysfunc(today()),-1,e),date9.)"d;

%put &amp;amp;firstdayofthelastmonth.;
%put &amp;amp;lastdayofthelastmonth.;

data t1;
  validfrom=&amp;amp;firstdayofthelastmonth;
  ValidTill=&amp;amp;lastdayofthelastmonth;

  put (_all_)(=) ;

  format validfrom validtill date9. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2023 20:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Store-Date-values-in-variables-and-concatenate/m-p/877970#M346868</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-05-28T20:19:53Z</dc:date>
    </item>
  </channel>
</rss>

