<?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 Proc expand: variable ... in list does not match type prescribed for this list in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657475#M197011</link>
    <description>&lt;P&gt;I receive the error : " variable ... in list does not match type prescribed for this list" when using the PROC EXPAND to get lead and lag of a variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this because the variable's type is character? it seems counterintuitive if it is the case. My code is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc expand data=input out=output method=none;
	by fund;
	id date;
	convert  = lag1 / transformout=(lag 1);
	convert name = name_lag2 / transformout=(lag 2);
	convert name = name_lag3 / transformout=(lag 3);
	convert name = name_lag4 / transformout=(lag 4);
	convert name = name_lag5 / transformout=(lag 5);

	convert name = name_lead1 / transformout=(lead 1);
	convert name = name_lead2 / transformout=(lead 2);
	convert name = name_lead3 / transformout=(lead 3);
	convert name = name_lead4 / transformout=(lead 4);
	convert name = name_lead5 / transformout=(lead 5);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jun 2020 12:32:29 GMT</pubDate>
    <dc:creator>somebody</dc:creator>
    <dc:date>2020-06-11T12:32:29Z</dc:date>
    <item>
      <title>Proc expand: variable ... in list does not match type prescribed for this list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657475#M197011</link>
      <description>&lt;P&gt;I receive the error : " variable ... in list does not match type prescribed for this list" when using the PROC EXPAND to get lead and lag of a variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this because the variable's type is character? it seems counterintuitive if it is the case. My code is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc expand data=input out=output method=none;
	by fund;
	id date;
	convert  = lag1 / transformout=(lag 1);
	convert name = name_lag2 / transformout=(lag 2);
	convert name = name_lag3 / transformout=(lag 3);
	convert name = name_lag4 / transformout=(lag 4);
	convert name = name_lag5 / transformout=(lag 5);

	convert name = name_lead1 / transformout=(lead 1);
	convert name = name_lead2 / transformout=(lead 2);
	convert name = name_lead3 / transformout=(lead 3);
	convert name = name_lead4 / transformout=(lead 4);
	convert name = name_lead5 / transformout=(lead 5);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 12:32:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657475#M197011</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2020-06-11T12:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand: variable ... in list does not match type prescribed for this list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657477#M197012</link>
      <description>&lt;P&gt;Also, how can I achieve this task without using a DATA step to descending sort to get LEAD values?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 12:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657477#M197012</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2020-06-11T12:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand: variable ... in list does not match type prescribed for this list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657481#M197014</link>
      <description>Could you please provide sample data and expected output</description>
      <pubDate>Thu, 11 Jun 2020 12:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657481#M197014</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-06-11T12:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand: variable ... in list does not match type prescribed for this list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657485#M197017</link>
      <description>&lt;P&gt;Regarding your first question, the &lt;A href="https://documentation.sas.com/?docsetId=etsug&amp;amp;docsetTarget=etsug_expand_syntax08.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en" target="_self"&gt;Convert Statement Documentation&lt;/A&gt; is pretty clear:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"The CONVERT statement lists the variables to be processed. Only numeric variables can be processed."&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 12:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657485#M197017</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-06-11T12:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand: variable ... in list does not match type prescribed for this list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657492#M197021</link>
      <description>&lt;P&gt;Regarding your second question. Do you want a way to do this &lt;EM&gt;with&lt;/EM&gt;&amp;nbsp;a data step or &lt;EM&gt;without&lt;/EM&gt; a data step?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 12:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657492#M197021</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-06-11T12:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand: variable ... in list does not match type prescribed for this list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657494#M197022</link>
      <description>&lt;P&gt;You do not have to sort the data twice you only need to sort it once by using fund and date as sort fields and utilize arrays in a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=inpdata; by fund date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you have 3 years of data you will have utmost 1096 dates so define an array of size 1095. This is an over kill but helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data out_data;&lt;/P&gt;
&lt;P&gt;length _name1 -- _name1096 $32.;&lt;/P&gt;
&lt;P&gt;set inpdata;&lt;/P&gt;
&lt;P&gt;by fund;&lt;/P&gt;
&lt;P&gt;array _names{1096} &amp;nbsp;_name1 -- _name1096;&lt;/P&gt;
&lt;P&gt;retain&amp;nbsp;_name1 -- _name1096 '';&lt;/P&gt;
&lt;P&gt;if first.fund then count=0;&lt;/P&gt;
&lt;P&gt;_names[count]=name;&lt;/P&gt;
&lt;P&gt;if last.fund then do;&lt;/P&gt;
&lt;P&gt;&amp;lt;look forward and backward in the array depending on the number of lags and leads&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;output&amp;gt;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code becomes hairier as you increase the number of variables you have to maintain for output increases. Or keep variables that you need to process and leave the others out. This can be joined back later.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 13:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657494#M197022</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-11T13:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand: variable ... in list does not match type prescribed for this list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657521#M197032</link>
      <description>&lt;P&gt;You can also do something like this. Just made up some data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    array names {19} $ 10 _temporary_ ('Alice', 'Barbara', 'Carol', 'Jane', 'Janet', 'Joyce', 'Judy', 'Louise', 'Mary', 'Alfred', 
                                    'Henry', 'James', 'Jeffrey', 'John', 'Philip', 'Robert', 'Ronald', 'Thomas', 'William');
    do id = 1 to 3;
        do date = '01jun2020'd to '10jun2020'd;
            name = names[ceil(rand("Uniform")*19)];
            output;
        end;
    end;
    format date ddmmyy10.;
run;

data want(drop=rc seq m i lname);
   if _N_=1 then do;
      declare hash h ();                    
      h.definekey('id', 'seq');
      h.definedata('lname');
      h.definedone();

      do seq = 1 by 1 until (lr1);
         set have end=lr1;
         h.replace(key : id, key : seq, data : name);
      end;
   end;

   array l {-3 : 3} $ 10 lag1-lag3 m lead1-lead3;
   
   do seq = 1 by 1 until (lr2);
      set have end=lr2;
      do i = -3 to 3;
         lname = repeat(' ', 10);
         rc = h.find (key : id, key : seq + i);
         l [i] = lname;
      end;
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 13:47:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-variable-in-list-does-not-match-type-prescribed-for/m-p/657521#M197032</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-06-11T13:47:06Z</dc:date>
    </item>
  </channel>
</rss>

