<?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 Condense a data set variables columns into one in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Condense-a-data-set-variables-columns-into-one/m-p/267679#M7429</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to create a condensed&amp;nbsp;dataset from one that has a stepwise apperence. I&amp;nbsp;started by thinking of listing the&amp;nbsp;column varables names and setting those varables names that repeat to the same column. I did this by collecting the names into double ampersand macro varables list, one appersand for the subgroup name and the other appersand for the count of repeated varables. Then I conducted a %if %else condition with %index. Now it seemed to work fine, but the &amp;nbsp;and find some TRUE results, but it dones't seem to like to output to static varable names:&lt;/P&gt;
&lt;PRE&gt;%else %if %index(&amp;amp;&amp;amp;b&amp;amp;i, 2)&amp;gt;0 %then C3=resolve('&amp;amp;&amp;amp;b&amp;amp;i');

MLOGIC(DOIT):  %IF condition %index(&amp;amp;&amp;amp;b&amp;amp;i, 2)&amp;gt;0 is TRUE
NOTE: Line generated by the invoked macro "DOIT".
36     C3=resolve('&amp;amp;&amp;amp;b&amp;amp;i')
       --
       22

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;,
              &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here bellow is a relpicated issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let a1 = a5;
%let a2 = a6;
%let a3 = a7;
%let a4 = a8;
%let obs = 4;

data prop;
	input a5 a6 a7 a8;
	n=_n_;
cards;
1 . . .
. 2 . .
. 2 . .
. . 3 .
. . 3 .
. . 3 .
. . . 4
. . . 4
. . . 4
. . . 4
;
run;
options mlogic;
%macro doit1();
data prop2;
	length f 3.;
	set prop;
	by n;
	%do i=1 %to &amp;amp;obs;
		%if %index(&amp;amp;&amp;amp;a&amp;amp;i,5)&amp;gt;0 %then e=&amp;amp;&amp;amp;a&amp;amp;i;
		%else %if %index(&amp;amp;&amp;amp;a&amp;amp;i,6)&amp;gt;0 %then e=&amp;amp;&amp;amp;a&amp;amp;i;
		%else %if %index(&amp;amp;&amp;amp;a&amp;amp;i,7)&amp;gt;0 %then e=&amp;amp;&amp;amp;a&amp;amp;i;
		%else %if %index(&amp;amp;&amp;amp;a&amp;amp;i,8)&amp;gt;0 %then e=&amp;amp;&amp;amp;a&amp;amp;i;
	%end;
run;
%mend;

%doit1;
options nomlogic;&lt;/PRE&gt;</description>
    <pubDate>Mon, 02 May 2016 17:31:07 GMT</pubDate>
    <dc:creator>rbikes</dc:creator>
    <dc:date>2016-05-02T17:31:07Z</dc:date>
    <item>
      <title>Condense a data set variables columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Condense-a-data-set-variables-columns-into-one/m-p/267679#M7429</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to create a condensed&amp;nbsp;dataset from one that has a stepwise apperence. I&amp;nbsp;started by thinking of listing the&amp;nbsp;column varables names and setting those varables names that repeat to the same column. I did this by collecting the names into double ampersand macro varables list, one appersand for the subgroup name and the other appersand for the count of repeated varables. Then I conducted a %if %else condition with %index. Now it seemed to work fine, but the &amp;nbsp;and find some TRUE results, but it dones't seem to like to output to static varable names:&lt;/P&gt;
&lt;PRE&gt;%else %if %index(&amp;amp;&amp;amp;b&amp;amp;i, 2)&amp;gt;0 %then C3=resolve('&amp;amp;&amp;amp;b&amp;amp;i');

MLOGIC(DOIT):  %IF condition %index(&amp;amp;&amp;amp;b&amp;amp;i, 2)&amp;gt;0 is TRUE
NOTE: Line generated by the invoked macro "DOIT".
36     C3=resolve('&amp;amp;&amp;amp;b&amp;amp;i')
       --
       22

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;,
              &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here bellow is a relpicated issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let a1 = a5;
%let a2 = a6;
%let a3 = a7;
%let a4 = a8;
%let obs = 4;

data prop;
	input a5 a6 a7 a8;
	n=_n_;
cards;
1 . . .
. 2 . .
. 2 . .
. . 3 .
. . 3 .
. . 3 .
. . . 4
. . . 4
. . . 4
. . . 4
;
run;
options mlogic;
%macro doit1();
data prop2;
	length f 3.;
	set prop;
	by n;
	%do i=1 %to &amp;amp;obs;
		%if %index(&amp;amp;&amp;amp;a&amp;amp;i,5)&amp;gt;0 %then e=&amp;amp;&amp;amp;a&amp;amp;i;
		%else %if %index(&amp;amp;&amp;amp;a&amp;amp;i,6)&amp;gt;0 %then e=&amp;amp;&amp;amp;a&amp;amp;i;
		%else %if %index(&amp;amp;&amp;amp;a&amp;amp;i,7)&amp;gt;0 %then e=&amp;amp;&amp;amp;a&amp;amp;i;
		%else %if %index(&amp;amp;&amp;amp;a&amp;amp;i,8)&amp;gt;0 %then e=&amp;amp;&amp;amp;a&amp;amp;i;
	%end;
run;
%mend;

%doit1;
options nomlogic;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 May 2016 17:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Condense-a-data-set-variables-columns-into-one/m-p/267679#M7429</guid>
      <dc:creator>rbikes</dc:creator>
      <dc:date>2016-05-02T17:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Condense a data set variables columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Condense-a-data-set-variables-columns-into-one/m-p/267685#M7430</link>
      <description>&lt;P&gt;You are mixing Macro and base SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't show what you actually want this to accomplish but take a look at the results from this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set prop;
   a5 = coalesce(a5,a6,a7,a8);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It moves all of the values from A5 to A8 into A5. You could drop the A6-A8 variables if you don't need them after this step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 17:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Condense-a-data-set-variables-columns-into-one/m-p/267685#M7430</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-02T17:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Condense a data set variables columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Condense-a-data-set-variables-columns-into-one/m-p/267722#M7431</link>
      <description>&lt;P&gt;Thanks for replying ballardw!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The function is great! I appericate your time, next time I will spicify what I am looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rbikes&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 20:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Condense-a-data-set-variables-columns-into-one/m-p/267722#M7431</guid>
      <dc:creator>rbikes</dc:creator>
      <dc:date>2016-05-02T20:51:31Z</dc:date>
    </item>
  </channel>
</rss>

