<?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: Sum and determine the stnd of columns that contain a certain text for each row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720330#M223138</link>
    <description>yes, so I want a column called total which sums up all the columns that had the variable week in them, and I want a column called stnd deviations that gives the standard deviation between the columns that had week in them, so something like this:&lt;BR /&gt;&lt;BR /&gt;data test;&lt;BR /&gt;input ID Char_Var Jan_week1 Jan_week2 Feb_week3 total stnd ;&lt;BR /&gt;datalines;&lt;BR /&gt;1 'prod1' 1 2 3 6 1&lt;BR /&gt;2 'prod2' 1 2 3 6 1&lt;BR /&gt;;&lt;BR /&gt;run;</description>
    <pubDate>Thu, 18 Feb 2021 21:29:45 GMT</pubDate>
    <dc:creator>Melika2</dc:creator>
    <dc:date>2021-02-18T21:29:45Z</dc:date>
    <item>
      <title>Sum and determine the stnd of columns that contain a certain text for each row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720323#M223133</link>
      <description>&lt;P&gt;I'm providing an example of a dataset I have below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input ID Char_Var Jan_week1 Jan_week2 Feb_week3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 'prod1' 1 2 3&lt;BR /&gt;2 'prod2' 1 2 3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to determine the total of the variables that have week in there, additionally I want to figure out the standard deviation and the change over the first and last week. However, my date variables will not always be like this.. i might have an extra week... it will change over time.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 20:56:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720323#M223133</guid>
      <dc:creator>Melika2</dc:creator>
      <dc:date>2021-02-18T20:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sum and determine the stnd of columns that contain a certain text for each row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720328#M223136</link>
      <description>&lt;P&gt;Can you provide more details?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 21:20:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720328#M223136</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-18T21:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sum and determine the stnd of columns that contain a certain text for each row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720330#M223138</link>
      <description>yes, so I want a column called total which sums up all the columns that had the variable week in them, and I want a column called stnd deviations that gives the standard deviation between the columns that had week in them, so something like this:&lt;BR /&gt;&lt;BR /&gt;data test;&lt;BR /&gt;input ID Char_Var Jan_week1 Jan_week2 Feb_week3 total stnd ;&lt;BR /&gt;datalines;&lt;BR /&gt;1 'prod1' 1 2 3 6 1&lt;BR /&gt;2 'prod2' 1 2 3 6 1&lt;BR /&gt;;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 18 Feb 2021 21:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720330#M223138</guid>
      <dc:creator>Melika2</dc:creator>
      <dc:date>2021-02-18T21:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sum and determine the stnd of columns that contain a certain text for each row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720331#M223139</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/242790"&gt;@Melika2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm providing an example of a dataset I have below:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;input ID Char_Var Jan_week1 Jan_week2 Feb_week3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 'prod1' 1 2 3&lt;BR /&gt;2 'prod2' 1 2 3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to determine the total of the variables that have week in there, additionally I want to figure out the standard deviation and the change over the first and last week. However, my date variables will not always be like this.. i might have an extra week... it will change over time.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is generally poor data structure to have data in the variable name. If you really &lt;STRONG&gt;must&lt;/STRONG&gt; do so with a word in the name of a variable then start the name with the piece you want to find instead of the end or buried in the middle. Week_Jan1 Week_Jan2 or some such.&lt;/P&gt;
&lt;P&gt;You may ask why. When you have a common start to variable names then SAS will allow specific forms of lists to reference them such as Week_:&amp;nbsp; the colon at the end tells SAS to use all the variables whose names start with Week_.&lt;/P&gt;
&lt;P&gt;So the functions like SUM will total the variables (assuming they are all numeric ) with code like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tot = sum (of Week_:);&lt;/P&gt;
&lt;P&gt;StdDev = std(of week_:) ;&lt;/P&gt;
&lt;P&gt;and so on. Then it doesn't matter if you don't know, at least for these functions, what the actual names are as long as they start the same.&lt;/P&gt;
&lt;P&gt;"first" and "last" week named the way you show them can raise a lot of questions. Like what happens when your "weeks" cross a calendar year boundary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generally you will in the long run find out that having the "week" as an actual date variable and the data structured as&lt;/P&gt;
&lt;P&gt;ID &amp;lt;other variables&amp;gt; date&amp;nbsp; value_variable (s)&lt;/P&gt;
&lt;P&gt;is more flexible. A big reason is that SAS provides a fair number of functions and formats to deal with variables whose values are dates. Not so much when the value is hidden in a variable name.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 21:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720331#M223139</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-18T21:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sum and determine the stnd of columns that contain a certain text for each row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720333#M223140</link>
      <description>total = sum(of jan_week:, of feb_week:);&lt;BR /&gt;stdn = std(of jan_week:, of feb_week:);&lt;BR /&gt;&lt;BR /&gt;You can either list the variables manually or use short cut reference methods of colons shown above. Unfortunately SAS variable shortcuts rely on the principle of prefix not suffixes.</description>
      <pubDate>Thu, 18 Feb 2021 21:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720333#M223140</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-18T21:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sum and determine the stnd of columns that contain a certain text for each row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720900#M223353</link>
      <description>This helped. Thank you!</description>
      <pubDate>Mon, 22 Feb 2021 13:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-and-determine-the-stnd-of-columns-that-contain-a-certain/m-p/720900#M223353</guid>
      <dc:creator>Melika2</dc:creator>
      <dc:date>2021-02-22T13:11:14Z</dc:date>
    </item>
  </channel>
</rss>

