<?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 SYMGET with LEFT function in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/SYMGET-with-LEFT-function/m-p/234433#M5908</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I copied the following code from internet. Can someone please tell me what this LEFT function (see below in bold) do here? I actually don't know the use of left function. Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*Duration of exercise each day of week;*/&lt;BR /&gt;%LET time1=2.0;&lt;BR /&gt;%LET time2=1.0;&lt;BR /&gt;%LET time3=0.5;&lt;BR /&gt;%LET time4=0.6;&lt;BR /&gt;%LET time5=0.2;&lt;BR /&gt;%LET time6=1.0;&lt;BR /&gt;%LET time7=1.2;&lt;BR /&gt;/*Exercise planned for each day of week ;*/&lt;BR /&gt;%let sport1 =bike;&lt;BR /&gt;%let sport2 =walk;&lt;BR /&gt;%let sport3 =jog;&lt;BR /&gt;%let sport4 =stretch;&lt;BR /&gt;%let sport5 =bike;&lt;BR /&gt;%let sport6 =swim;&lt;BR /&gt;%let sport7 =walk;&lt;/P&gt;
&lt;P&gt;DATA eachday &lt;BR /&gt;wholeweek (KEEP = calsofar timesofar RENAME = (calsofar=calperweek timesofar=hrsperweek));&lt;BR /&gt;DO day = 1 TO 7;&lt;BR /&gt;LENGTH sport intensity $8 ;&lt;BR /&gt;&lt;STRONG&gt;sport = SYMGET('sport'||LEFT(day)) ;&lt;/STRONG&gt;&lt;BR /&gt;IF sport IN ('bike','swim','jog') THEN intensity = 'hard';&lt;BR /&gt;ELSE IF sport IN ('walk','dance') THEN intensity = 'moderate' ;&lt;BR /&gt;ELSE IF sport IN ('stretch','golf') THEN intensity = 'easy' ;&lt;BR /&gt;cal_num = INPUT(SYMGET(intensity),4.) ;&lt;BR /&gt;&lt;STRONG&gt;time = INPUT(SYMGET('time'||LEFT(day)),6.1) ;&lt;/STRONG&gt;&lt;BR /&gt;totalcal = time*cal_num ;&lt;BR /&gt;calsofar = SUM(calsofar, totalcal) ;&lt;BR /&gt;timesofar = SUM(timesofar, time) ;&lt;BR /&gt;RETAIN calsofar timesofar ;&lt;BR /&gt;OUTPUT eachday ;&lt;BR /&gt;IF day = 7 THEN OUTPUT wholeweek ;&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2015 18:24:02 GMT</pubDate>
    <dc:creator>mlogan</dc:creator>
    <dc:date>2015-11-12T18:24:02Z</dc:date>
    <item>
      <title>SYMGET with LEFT function</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SYMGET-with-LEFT-function/m-p/234433#M5908</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I copied the following code from internet. Can someone please tell me what this LEFT function (see below in bold) do here? I actually don't know the use of left function. Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*Duration of exercise each day of week;*/&lt;BR /&gt;%LET time1=2.0;&lt;BR /&gt;%LET time2=1.0;&lt;BR /&gt;%LET time3=0.5;&lt;BR /&gt;%LET time4=0.6;&lt;BR /&gt;%LET time5=0.2;&lt;BR /&gt;%LET time6=1.0;&lt;BR /&gt;%LET time7=1.2;&lt;BR /&gt;/*Exercise planned for each day of week ;*/&lt;BR /&gt;%let sport1 =bike;&lt;BR /&gt;%let sport2 =walk;&lt;BR /&gt;%let sport3 =jog;&lt;BR /&gt;%let sport4 =stretch;&lt;BR /&gt;%let sport5 =bike;&lt;BR /&gt;%let sport6 =swim;&lt;BR /&gt;%let sport7 =walk;&lt;/P&gt;
&lt;P&gt;DATA eachday &lt;BR /&gt;wholeweek (KEEP = calsofar timesofar RENAME = (calsofar=calperweek timesofar=hrsperweek));&lt;BR /&gt;DO day = 1 TO 7;&lt;BR /&gt;LENGTH sport intensity $8 ;&lt;BR /&gt;&lt;STRONG&gt;sport = SYMGET('sport'||LEFT(day)) ;&lt;/STRONG&gt;&lt;BR /&gt;IF sport IN ('bike','swim','jog') THEN intensity = 'hard';&lt;BR /&gt;ELSE IF sport IN ('walk','dance') THEN intensity = 'moderate' ;&lt;BR /&gt;ELSE IF sport IN ('stretch','golf') THEN intensity = 'easy' ;&lt;BR /&gt;cal_num = INPUT(SYMGET(intensity),4.) ;&lt;BR /&gt;&lt;STRONG&gt;time = INPUT(SYMGET('time'||LEFT(day)),6.1) ;&lt;/STRONG&gt;&lt;BR /&gt;totalcal = time*cal_num ;&lt;BR /&gt;calsofar = SUM(calsofar, totalcal) ;&lt;BR /&gt;timesofar = SUM(timesofar, time) ;&lt;BR /&gt;RETAIN calsofar timesofar ;&lt;BR /&gt;OUTPUT eachday ;&lt;BR /&gt;IF day = 7 THEN OUTPUT wholeweek ;&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 18:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SYMGET-with-LEFT-function/m-p/234433#M5908</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2015-11-12T18:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: SYMGET with LEFT function</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SYMGET-with-LEFT-function/m-p/234452#M5911</link>
      <description>&lt;P&gt;The LEFT() function left aligns the text in a character string. So basically it moves the leading blanks to trailing blanks.&lt;/P&gt;
&lt;P&gt;In this case the programming is taking advantage of SAS's ability to automatically convert a numeric varaible DAY to a character string. But since SAS uses the BEST12. format when it does that there will be leading spaces in the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you were wrting this code now you would use the CATS() function. This will avoid the need for the LEFT() funcaiton and also the annoying warning about automatic converstion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;STRONG&gt;sport = SYMGET(cats('sport',day));&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 19:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SYMGET-with-LEFT-function/m-p/234452#M5911</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-11-12T19:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: SYMGET with LEFT function</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SYMGET-with-LEFT-function/m-p/234460#M5912</link>
      <description>left function will move the blank spaces in the beginning of the character variable day to right side. so that the values created will be like sport1,sport2,sport3..... if left is not used then there is a chance that the values created will be sport 1 , sport 2 ............. which will not resolve the macro variables to convert into values.</description>
      <pubDate>Thu, 12 Nov 2015 19:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SYMGET-with-LEFT-function/m-p/234460#M5912</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-11-12T19:43:28Z</dc:date>
    </item>
  </channel>
</rss>

