<?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: Missing Variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104171#M29116</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understood what you mean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data b;
infile 'c:\temp\b.txt' firstobs=2 expandtabs;
input date : ddmmyy10. code value;
monyy=put(date,monyy7.);
format date ddmmyy10.;
run;
data funds;
infile 'c:\temp\funds.txt' firstobs=2 expandtabs;
input&amp;nbsp; code ;
run;
data date;
infile 'c:\temp\date.txt' firstobs=2 expandtabs;
input date : ddmmyy10.;
monyy=put(date,monyy7.);
format date ddmmyy10.;
run;
proc sql;
create table have as
select x.*,value
 from b right join
 (select * from (select distinct code from funds),(select distinct monyy from date)) as x
 on&amp;nbsp; b.code = x.code and b.monyy=x.monyy;
quit;
 
proc transpose data=have out=want(drop=_name_) ;
by code;
id monyy;
var value;
run;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 May 2012 04:53:55 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2012-05-07T04:53:55Z</dc:date>
    <item>
      <title>Missing Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104166#M29111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need your help in an issue I am facing. I have a file with the fund's holdings (B), another one with all the funds' codes (Funds) and the third one with all the holding periods (Date). My problem is that at the final stage some of the dates, which have become the variables, are missing. What should I do to keep all the dates instead of only keeping the ones that there exist holdings?&lt;/P&gt;&lt;P&gt;Below is my code: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table f as&lt;BR /&gt;select a.*,b.* &lt;BR /&gt;from work.Date as a left join work.b as b&lt;BR /&gt;on a.date=b.date;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc sort data=work.f nodupkey;by code date;run;&lt;BR /&gt;data a; set f; format date monyy7.; run; &lt;BR /&gt;proc sql; create table a_ as select distinct date,0.1 as code from a; quit;&lt;/P&gt;&lt;P&gt;data a2; set a a_;run;&lt;BR /&gt;proc sort data= a2; by code date;run;&lt;BR /&gt;proc transpose data=a2 out=a3(where=(code^=0.1));&lt;BR /&gt;by code;&lt;BR /&gt;id date;&lt;BR /&gt;var value;&lt;BR /&gt;run;&lt;BR /&gt;data work.a4;&lt;BR /&gt;set work.a3;&lt;BR /&gt;drop _NAME_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table a5 as&lt;BR /&gt;select a.*,b.* &lt;BR /&gt;from work.funds as a left join work.a4 as b&lt;BR /&gt;on a.code=b.code;&lt;BR /&gt;quit;&lt;BR /&gt;proc freq data=a5;run;&lt;/P&gt;&lt;P&gt;data asigns;&lt;BR /&gt;set WORK.a5;&lt;BR /&gt;array vol(63) mar1995 --jun2010;&lt;BR /&gt;array si (62) $&amp;nbsp; si1-si62;&lt;BR /&gt;do i= 2 to 63;&lt;BR /&gt;if vol(i) &amp;gt; vol(i-1) then si(i-1)='+';&lt;BR /&gt;else if vol(i) &amp;lt;&amp;nbsp; vol(i-1) then si(i-1)='-';&lt;BR /&gt;else si(i-1)='&amp;amp;';&lt;BR /&gt;end;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 16:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104166#M29111</guid>
      <dc:creator>Costasg</dc:creator>
      <dc:date>2012-05-04T16:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Missing Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104167#M29112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are you trying to do with these three tables? What is the expected result?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 17:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104167#M29112</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-05-04T17:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Missing Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104168#M29113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;well actually the problem is that one variable (SEP2010) is in the wrong order, instead of last one is 8th. I am attaching the output.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 17:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104168#M29113</guid>
      <dc:creator>Costasg</dc:creator>
      <dc:date>2012-05-04T17:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Missing Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104169#M29114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suspect you may be getting unexpected results with your array statement: array vol(63) mar1995 --jun2010&lt;/P&gt;&lt;P&gt;processing things in an order you aren't expecting.&lt;/P&gt;&lt;P&gt;You might want to put this code in the middle of your array processing loop to see if that is happening:&lt;/P&gt;&lt;P&gt;do i = 2 to 63;&lt;/P&gt;&lt;P&gt;y= vname (vol(i));&lt;/P&gt;&lt;P&gt;put y=;&lt;/P&gt;&lt;P&gt;&amp;lt;other code&amp;gt;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop y;&lt;/P&gt;&lt;P&gt;look in the log for the sequence of the values of y.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 17:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104169#M29114</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-05-04T17:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Missing Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104170#M29115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, it is unlikely to be the problem there. I realized that the problem lies earlier, before the A3 table when I transpose the data. I have highlighted the code. Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table f as&lt;BR /&gt;select a.*,b.* &lt;BR /&gt;from work.Date as a left join work.b as b&lt;BR /&gt;on a.date=b.date;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc sort data=work.f nodupkey;by date code;run;&lt;BR /&gt;data a; set f; format date monyy7.; run; &lt;BR /&gt;proc sql; create table a_ as select distinct date,0.1 as code from a; quit;&lt;/P&gt;&lt;P&gt;data a2; set a a_;run;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;proc sort data= a2; by code date;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;proc transpose data=a2 out=a3(where=(code^=0.1));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;by code;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;id date;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;var value;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;data work.a4;&lt;BR /&gt;set work.a3;&lt;BR /&gt;drop _NAME_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table a5 as&lt;BR /&gt;select a.*,b.* &lt;BR /&gt;from work.funds as a left join work.a4 as b&lt;BR /&gt;on a.code=b.code;&lt;BR /&gt;quit;&lt;BR /&gt;proc freq data=a5;run;&lt;/P&gt;&lt;P&gt;data asigns;&lt;BR /&gt;set WORK.a5;&lt;BR /&gt;array vol(63) mar1995 --sep2010;&lt;BR /&gt;array si (62) $&amp;nbsp; si1-si62;&lt;BR /&gt;do i= 2 to 63;&lt;BR /&gt;if vol(i) &amp;gt; vol(i-1) then si(i-1)='+';&lt;BR /&gt;else if vol(i) &amp;lt;&amp;nbsp; vol(i-1) then si(i-1)='-';&lt;BR /&gt;else si(i-1)='&amp;amp;';&lt;BR /&gt;end;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 18:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104170#M29115</guid>
      <dc:creator>Costasg</dc:creator>
      <dc:date>2012-05-04T18:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Missing Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104171#M29116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understood what you mean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data b;
infile 'c:\temp\b.txt' firstobs=2 expandtabs;
input date : ddmmyy10. code value;
monyy=put(date,monyy7.);
format date ddmmyy10.;
run;
data funds;
infile 'c:\temp\funds.txt' firstobs=2 expandtabs;
input&amp;nbsp; code ;
run;
data date;
infile 'c:\temp\date.txt' firstobs=2 expandtabs;
input date : ddmmyy10.;
monyy=put(date,monyy7.);
format date ddmmyy10.;
run;
proc sql;
create table have as
select x.*,value
 from b right join
 (select * from (select distinct code from funds),(select distinct monyy from date)) as x
 on&amp;nbsp; b.code = x.code and b.monyy=x.monyy;
quit;
 
proc transpose data=have out=want(drop=_name_) ;
by code;
id monyy;
var value;
run;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2012 04:53:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104171#M29116</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-05-07T04:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Missing Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104172#M29117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many Thanks Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2012 08:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Missing-Variables/m-p/104172#M29117</guid>
      <dc:creator>Costasg</dc:creator>
      <dc:date>2012-05-07T08:02:05Z</dc:date>
    </item>
  </channel>
</rss>

