<?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: Adding columns based on condition in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717669#M38101</link>
    <description>&lt;P&gt;Do not think of it as ADDING variables.&amp;nbsp; Think of it as assuring that ALL of the variables are defined.&amp;nbsp; So if you want make sure that the variables V1 to V30 are all defined then just add a statement that defines them.&amp;nbsp; Like a LENGTH statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if V1 to V30 are supposed to be numeric you would do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  length v1-v30 8;
  set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If they are supposed to be character then use $ before the length value in the LENGTH statement.&lt;/P&gt;</description>
    <pubDate>Mon, 08 Feb 2021 17:37:43 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-02-08T17:37:43Z</dc:date>
    <item>
      <title>Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717591#M38088</link>
      <description>&lt;P&gt;Hi everyone, i am beginner despite of SAS and i would be glad if you help me with this problem.&lt;BR /&gt;Imagine you have columns for example:&lt;BR /&gt;V1 V2 V3 V4 V5 V6 V7&lt;BR /&gt;Now i want to add code which complete this row of columns to V30. But you don't know which column is the last one. So you have to find him and based on this info complete row of columns to V30.&lt;BR /&gt;Assume that columns which are already there could contain some data but it's not neccesary.&lt;BR /&gt;I hope my description is sufficient. If not i can add some more details. Thank you very much for willingnes and your time.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 15:36:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717591#M38088</guid>
      <dc:creator>matus2711</dc:creator>
      <dc:date>2021-02-08T15:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717592#M38089</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;So you have to find them ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Find them how? Yes, please explain in more detail.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 15:30:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717592#M38089</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-08T15:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717595#M38090</link>
      <description>&lt;P&gt;Find that last column, in whole dataset it can be any column, but more often the last one is V13, V14 or V15 for example. So for example you detect that last column in this part of dataset is V13 so you then just add others to number 30. My problem is that i don't know which functions are best for it.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 15:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717595#M38090</guid>
      <dc:creator>matus2711</dc:creator>
      <dc:date>2021-02-08T15:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717600#M38091</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/368382"&gt;@matus2711&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Find that last column, in whole dataset it can be any column, but more often the last one is V13, V14 or V15 for example. So for example you detect that last column in this part of dataset is V13 so you then just add others to number 30. My problem is that i don't know which functions are best for it.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm afraid I can't grasp enough meaning here to write a program. Show us a small example, explain what you have and what you want to have.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 15:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717600#M38091</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-08T15:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717601#M38092</link>
      <description>&lt;P&gt;I would need more information, as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but to start to answer your questions:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) This is not an Enterprise Guide question, it is a SAS programming question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) One can add column using this syntax.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length v8-v30 8;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;that's going to add 23 numeric columns to your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3) This code will access the metadata of the dataset "HAVE" and create a table, one row per column.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select *
    from dictionary.Columns
    where libname="WORK"
      AND memname="HAVE"
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;using this type of query one can "count" how many columns are in a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717601#M38092</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-02-08T17:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717608#M38093</link>
      <description>Imagine you have columns, e.g.&lt;BR /&gt;V1 V2 V3 V4 V5&lt;BR /&gt;1. detect or find number of last column, i don't want hardcode them&lt;BR /&gt;2. complete row of columns (V1 V2 V3 V4 V5) to V30&lt;BR /&gt;Which type of additional info you need for this?</description>
      <pubDate>Mon, 08 Feb 2021 15:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717608#M38093</guid>
      <dc:creator>matus2711</dc:creator>
      <dc:date>2021-02-08T15:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717618#M38094</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/368382"&gt;@matus2711&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Imagine you have columns, e.g.&lt;BR /&gt;V1 V2 V3 V4 V5&lt;BR /&gt;1. detect or find number of last column, i don't want hardcode them&lt;BR /&gt;2. complete row of columns (V1 V2 V3 V4 V5) to V30&lt;BR /&gt;Which type of additional info you need for this?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your examples keep talking about V30, why? What does that have to do with the fact that you have columns V1 V2 V3 V4 V5?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 16:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717618#M38094</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-08T16:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717620#M38095</link>
      <description>&lt;P&gt;OK, question then, if one might imagine the variables B1 through B5. Would one want, then, variables B6 through B30?&amp;nbsp; That is are you wanting to keep the same prefix?&amp;nbsp; in your case "V" and in this case "B".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 16:04:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717620#M38095</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-02-08T16:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717650#M38096</link>
      <description>&lt;P&gt;Exactly i want to keep same prefix. thank you for patience&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717650#M38096</guid>
      <dc:creator>matus2711</dc:creator>
      <dc:date>2021-02-08T17:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717654#M38097</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to understand,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you have something like this table:&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Image1.PNG" style="width: 629px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54464i06830DB8054B5B9A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image1.PNG" alt="Image1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;do you want to add the missing columns (in this example from V13 to V30) to the table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717654#M38097</guid>
      <dc:creator>Dani_Gor</dc:creator>
      <dc:date>2021-02-08T17:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717655#M38098</link>
      <description>&lt;P&gt;Because i want to expand dataset to column V30 or B30 or P30, that doesn't matter. Sorry for inaccurate description.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717655#M38098</guid>
      <dc:creator>matus2711</dc:creator>
      <dc:date>2021-02-08T17:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717656#M38099</link>
      <description>&lt;P&gt;Yes exactly but you have to keep assumption that in dataset there are not all the columns same and because of that i can't hardcode them by e.g. alter table command.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:08:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717656#M38099</guid>
      <dc:creator>matus2711</dc:creator>
      <dc:date>2021-02-08T17:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717669#M38101</link>
      <description>&lt;P&gt;Do not think of it as ADDING variables.&amp;nbsp; Think of it as assuring that ALL of the variables are defined.&amp;nbsp; So if you want make sure that the variables V1 to V30 are all defined then just add a statement that defines them.&amp;nbsp; Like a LENGTH statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if V1 to V30 are supposed to be numeric you would do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  length v1-v30 8;
  set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If they are supposed to be character then use $ before the length value in the LENGTH statement.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717669#M38101</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-08T17:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717679#M38102</link>
      <description>&lt;P&gt;Thank you very much. Amazing how simple the solution is&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 18:03:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717679#M38102</guid>
      <dc:creator>matus2711</dc:creator>
      <dc:date>2021-02-08T18:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Adding columns based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717723#M38103</link>
      <description>Now I see.  If you care to understand more about this subject in SAS in the&lt;BR /&gt;future, a good term  to remember is SAS "Program data vector" or PDV.&lt;BR /&gt;Which is what I would have spoken to if I saw what you were dealing with in&lt;BR /&gt;time.  There was a similar question asked about ordering of variables in&lt;BR /&gt;the last two weeks.&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Feb 2021 20:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Adding-columns-based-on-condition/m-p/717723#M38103</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-02-08T20:07:47Z</dc:date>
    </item>
  </channel>
</rss>

