<?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: an inquiry in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528528#M73630</link>
    <description>this code is working but it does not exclude the companies that do not have the data for all years.&lt;BR /&gt;thanks</description>
    <pubDate>Sat, 19 Jan 2019 14:57:30 GMT</pubDate>
    <dc:creator>Radwan</dc:creator>
    <dc:date>2019-01-19T14:57:30Z</dc:date>
    <item>
      <title>an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528507#M73624</link>
      <description>&lt;P&gt;Hello everyone&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a huge data for 15 years and for more than 2500 firms. so far it is fine, but when i started analyzing the data i found out that some companies do not have complete data for 15 years. so i tried to use If statement as follows.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cashflow; set Radwan; 
if year= 2000 2001 2002 .... ; run; &lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;unfortunately&amp;nbsp; it does not work except when i use only one year as follows: so please help me through giving me the right code to remove the firms that do not have the data for my research period.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cashflow; set Radwan; 
if year= 2000;  run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Jan 2019 09:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528507#M73624</guid>
      <dc:creator>Radwan</dc:creator>
      <dc:date>2019-01-19T09:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528510#M73625</link>
      <description>&lt;P&gt;How is your data structured? Please provide an example of what your data looks like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the research period always from 2000 to 2015 or can it be any 15 consecutive years?&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jan 2019 10:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528510#M73625</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-19T10:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528521#M73626</link>
      <description>&lt;P&gt;This is not the simplest problem, since SAS processes a single observation at a time.&amp;nbsp; It sounds like you need a tool to examine a set of observations (all the observations for a company) to see what data is there.&amp;nbsp; Does that sound right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you examined your data to determine whether it might contain two observations for the same company/year combination?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What would you like the result to be ... throw out companies with missing values?&amp;nbsp; Fill in missing values with zeros?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The planning is the harder part.&amp;nbsp; The programming might not be simple, but it isn't as difficult as the planning.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jan 2019 14:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528521#M73626</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-19T14:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528523#M73627</link>
      <description>&lt;P&gt;try using an in condition&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cashflow; 
set Radwan; 
if year in (2000, 2001, 2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015); 
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Jan 2019 14:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528523#M73627</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-01-19T14:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528525#M73628</link>
      <description>yes, the research period is 2000 - 2015.&lt;BR /&gt;my data look like ( code , year, cashflow) those are the variables</description>
      <pubDate>Sat, 19 Jan 2019 14:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528525#M73628</guid>
      <dc:creator>Radwan</dc:creator>
      <dc:date>2019-01-19T14:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528526#M73629</link>
      <description>i have checked my data, as i said some companies do not have the data of 15 years so i need to delete such companies.</description>
      <pubDate>Sat, 19 Jan 2019 14:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528526#M73629</guid>
      <dc:creator>Radwan</dc:creator>
      <dc:date>2019-01-19T14:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528528#M73630</link>
      <description>this code is working but it does not exclude the companies that do not have the data for all years.&lt;BR /&gt;thanks</description>
      <pubDate>Sat, 19 Jan 2019 14:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528528#M73630</guid>
      <dc:creator>Radwan</dc:creator>
      <dc:date>2019-01-19T14:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528529#M73631</link>
      <description>&lt;P&gt;While PROC SQL can handle this in a straightforward way, my expertise is more in a DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by company year;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;count=0;&lt;/P&gt;
&lt;P&gt;do until (last.company);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;where (2000 &amp;lt;= year &amp;lt;= 2015);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by company;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;count + 1;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.company);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;where (2000 &amp;lt;= year &amp;lt;= 2015);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if count = 16 then output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop count;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The top loops counts the number of observations for a company, within the proper set of years.&amp;nbsp; (Note that I allowed that a company might have data for years outside the desired range, but only counted those in the proper set of years.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The bottom loop reads the same observations, then outputs them if all the data is there.&amp;nbsp; Note that the range you specified is 16 years, not 15 years.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jan 2019 15:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528529#M73631</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-19T15:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528530#M73632</link>
      <description>do you mean (company) as code ?&lt;BR /&gt;because i use code as variables for the companies</description>
      <pubDate>Sat, 19 Jan 2019 15:09:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528530#M73632</guid>
      <dc:creator>Radwan</dc:creator>
      <dc:date>2019-01-19T15:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528531#M73633</link>
      <description>&lt;P&gt;Yes.&amp;nbsp; Use CODE instead of COMPANY.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jan 2019 15:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528531#M73633</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-19T15:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528532#M73634</link>
      <description>i just tried this code but i got error message (proc sort data=have;&lt;BR /&gt;&lt;BR /&gt;by company year;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;&lt;BR /&gt;count=0;&lt;BR /&gt;&lt;BR /&gt;do until (last.company);&lt;BR /&gt;&lt;BR /&gt;set have;&lt;BR /&gt;&lt;BR /&gt;where (2000 &amp;lt;= year &amp;lt;= 2015);&lt;BR /&gt;&lt;BR /&gt;by company;&lt;BR /&gt;&lt;BR /&gt;count + 1;&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;do until (last.company);&lt;BR /&gt;&lt;BR /&gt;set have;&lt;BR /&gt;&lt;BR /&gt;where (2000 &amp;lt;= year &amp;lt;= 2015);&lt;BR /&gt;&lt;BR /&gt;if count = 16 then output;&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;drop count;&lt;BR /&gt;&lt;BR /&gt;run;)&lt;BR /&gt;</description>
      <pubDate>Sat, 19 Jan 2019 15:21:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528532#M73634</guid>
      <dc:creator>Radwan</dc:creator>
      <dc:date>2019-01-19T15:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528533#M73635</link>
      <description>&lt;P&gt;It looks like you haven't yet replaced "company" with "code" as the variable name.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jan 2019 15:22:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528533#M73635</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-19T15:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528535#M73636</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="111.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26375iF3398FC2A9D89F3A/image-size/large?v=v2&amp;amp;px=999" role="button" title="111.png" alt="111.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jan 2019 15:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528535#M73636</guid>
      <dc:creator>Radwan</dc:creator>
      <dc:date>2019-01-19T15:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528536#M73637</link>
      <description>&lt;P&gt;This means that YEAR (in your data set) is character, not numeric.&amp;nbsp; Change both WHERE statements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where ("2000" &amp;lt;= year &amp;lt;= "2015");&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jan 2019 15:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528536#M73637</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-19T15:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528537#M73638</link>
      <description>ohhhhh yes you are right . thanks</description>
      <pubDate>Sat, 19 Jan 2019 15:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528537#M73638</guid>
      <dc:creator>Radwan</dc:creator>
      <dc:date>2019-01-19T15:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: an inquiry</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528566#M73639</link>
      <description>&lt;P&gt;Alternatively you can do this. It is not as efficient, but it ensures that every relevant year is actually present for each firm.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length code $10;
code='one';
do year=2000 to 2015;
   cashflow=rand('integer', 1000, 10000);
   output;
end;
code='two';
do year=2000 to 2013;
   cashflow=rand('integer', 1000, 10000);
   output;
end;
code='three';
do year=2000 to 2015;
   cashflow=rand('integer', 1000, 10000);
   output;
end;
run;

proc sort data=have;
   by code;
run;

proc transpose data=have out=temp prefix=year;
    by code;
    id year;
    var cashflow;
run;

data want(keep=code year cashflow);
   set temp;
   array years{*} year2000-year2015;
   if nmiss(of years[*])=0 then do i=1 to dim(years);
      cashflow=years[i];
      year=input(compress(vname(years[i]), '0123456789', 'k'), 8.);
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Jan 2019 20:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-inquiry/m-p/528566#M73639</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-19T20:21:23Z</dc:date>
    </item>
  </channel>
</rss>

