<?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: add quote to value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514715#M138812</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215650"&gt;@jojozheng&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;WHEN i %PUT &amp;amp;date_last&lt;BR /&gt;it will show in log : '30sep2018'd&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm afraid I don't understand why the end goal is a %PUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Are you going to use this macro variable somewhere in the rest of your code?&lt;/STRONG&gt; If so, you absolutely don't need the quote or the letter "d" at the end, you are working way to hard to accomplish something that is not needed. In that case, you need the macro variable to contain the SAS date value (which is an integer).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Several people have now told you that you don't need a macro variable to contain quotes, that there are simpler ways to get what you want.&lt;/P&gt;</description>
    <pubDate>Tue, 20 Nov 2018 12:03:53 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-11-20T12:03:53Z</dc:date>
    <item>
      <title>add quote to value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514633#M138771</link>
      <description>&lt;P&gt;hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add quote to date value: 30sep2018 30sep2013&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set ret_mon_1; ---------table has date value =30sep2018 and 30sep2013&lt;BR /&gt;call symputx('date_last',(put(date, date9.)));&lt;BR /&gt;call symputx('date_first',(%quote(put(first_date, date9.))));&lt;BR /&gt;put date first_date;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%let date=%sysfunc(cats(%quote(&amp;amp;date_last),d));&lt;BR /&gt;%put &amp;amp;date;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want&amp;nbsp; to call 2 above dates : date='30sep2018'd&amp;nbsp; first_date='30sep2013'd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know why %quote cannot be used.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 23:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514633#M138771</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-11-19T23:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: add quote to value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514639#M138773</link>
      <description>Use the QUOTE not %QUOTE function. Also, if you don't format the dates (using PUT), it will work as desired without any formats.</description>
      <pubDate>Mon, 19 Nov 2018 23:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514639#M138773</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-19T23:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: add quote to value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514641#M138775</link>
      <description>thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;BR /&gt;you mean like below:&lt;BR /&gt;call symputx('date_last',(put(date)));&lt;BR /&gt;or can you specify for me?&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Nov 2018 23:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514641#M138775</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-11-19T23:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: add quote to value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514643#M138777</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215650"&gt;@jojozheng&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Broader observation first: you need to better understand the macro scanning process - assignments using &amp;amp; and % commands take place BEFORE data step execution. Please review macro documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your requirement is to add quotes to existing date value in a data set during execution, then macro assignments are unnecessary - the put() and cat() functions will suffice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample code below.&amp;nbsp;&lt;EM&gt;I'm assuming your dates are stored as numerics&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data MyDates;
	infile datalines;
	input DateVal:date9.;
	DateStr1=cat("'",put(DateVal,date9.),"'"); /* Surround date with single quotes */
	DateStr2=cat('"',put(DateVal,date9.),'"'); /* Surround date with double quotes */
datalines;
30sep2018
30sep2013
run;&lt;/CODE&gt;&lt;/PRE&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>Tue, 20 Nov 2018 00:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514643#M138777</guid>
      <dc:creator>AndrewHowell</dc:creator>
      <dc:date>2018-11-20T00:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: add quote to value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514644#M138778</link>
      <description>&lt;P&gt;Macros are not needed here and in fact just make things much more complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    set ret_mon_1; 
    call symputx('date_last',input(date,date9.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I want&amp;nbsp; to call 2 above dates : date='30sep2018'd&amp;nbsp; first_date='30sep2013'd&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This really doesn't mean anything to me, Call how? What code will you use them in?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 00:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514644#M138778</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-20T00:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: add quote to value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514645#M138779</link>
      <description>WHEN i %PUT &amp;amp;date_last&lt;BR /&gt;it will show in log : '30sep2018'd</description>
      <pubDate>Tue, 20 Nov 2018 00:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514645#M138779</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-11-20T00:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: add quote to value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514646#M138780</link>
      <description>Yeah, that view is really only good for display, formats are not needed. PUT converts the numeric date to a character variable which is adding work for yourself. If you leave it as a SAS date, which is a number, it will be easier to work with.</description>
      <pubDate>Tue, 20 Nov 2018 00:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514646#M138780</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-20T00:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: add quote to value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514649#M138783</link>
      <description>&lt;P&gt;You are working too hard.&lt;/P&gt;
&lt;P&gt;First if you already have a macro variable with a value that is compatible with the DATE informat then you can use it directly as a date literal by adding the quotes and trailing d.&amp;nbsp; You do NOT want to use single quotes since the macro variable reference will not resolve inside of single quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date_last=30SEP2018;
%let date_literal="&amp;amp;date_last"d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Second you don't need to use the human readable date literal syntax.&amp;nbsp; You can just use the actual numeric value.&amp;nbsp; So no need for quotes or PUT() function.&lt;/P&gt;
&lt;P&gt;Try this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  date='30SEP2018'd ;
  first_date='30SEP2013'd;
  call symputx('date_last',date);
  call symputx('date_first',first_date);
  call symputx('date_last_human',quote(put(date,date9.))||'d');
  call symputx('date_first_human',quote(put(first_date,date9.))||'d');
  put (date first_date) (=) ;
  put (date first_date) (= date9.) ;
run;

%put &amp;amp;=date_last &amp;amp;=date_first;
%put &amp;amp;=date_last_human &amp;amp;=date_first_human;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;date=21457 first_date=19631
date=30SEP2018 first_date=30SEP2013
NOTE: DATA statement used (Total process time):
      real time           0.18 seconds
      cpu time            0.01 seconds


1247
1248  %put &amp;amp;=date_last &amp;amp;=date_first;
DATE_LAST=21457 DATE_FIRST=19631
1249  %put &amp;amp;=date_last_human &amp;amp;=date_first_human;
DATE_LAST_HUMAN="30SEP2018"d DATE_FIRST_HUMAN="30SEP2013"d&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 01:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514649#M138783</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-11-20T01:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: add quote to value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514715#M138812</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215650"&gt;@jojozheng&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;WHEN i %PUT &amp;amp;date_last&lt;BR /&gt;it will show in log : '30sep2018'd&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm afraid I don't understand why the end goal is a %PUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Are you going to use this macro variable somewhere in the rest of your code?&lt;/STRONG&gt; If so, you absolutely don't need the quote or the letter "d" at the end, you are working way to hard to accomplish something that is not needed. In that case, you need the macro variable to contain the SAS date value (which is an integer).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Several people have now told you that you don't need a macro variable to contain quotes, that there are simpler ways to get what you want.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 12:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-quote-to-value/m-p/514715#M138812</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-20T12:03:53Z</dc:date>
    </item>
  </channel>
</rss>

