<?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: How to insert a missing value to a missing record ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383532#M91479</link>
    <description>&lt;P&gt;Do you have a list or table of the all 80 locations ?&lt;/P&gt;
&lt;P&gt;Do you expect to have the 4 entry_codes for all locations?&lt;/P&gt;
&lt;P&gt;Assuming you deal now with one quarter only then do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data help;
   set locations;
       retain quarter 173;
       do entry_code = 1 to 4; output; end;
run;

data want;
  merge help have;
  by quarter location entry_code;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 28 Jul 2017 01:09:05 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-07-28T01:09:05Z</dc:date>
    <item>
      <title>How to insert a missing value to a missing record ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383520#M91471</link>
      <description>&lt;P&gt;Dear SAS user community,&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; I extra data from oracle tables through sas software.&lt;BR /&gt;The data layout as follow:&lt;BR /&gt;quarter&amp;nbsp; location&amp;nbsp;&amp;nbsp; entry_code&amp;nbsp; volume&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (about 20 vars in total)&lt;BR /&gt;173&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loc_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 150&lt;BR /&gt;173&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loc_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50&lt;BR /&gt;173&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loc_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&lt;BR /&gt;173&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loc_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 300&lt;BR /&gt;....................................&lt;BR /&gt;173&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loc_2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&lt;BR /&gt;173&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loc_2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 100&lt;BR /&gt;173&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loc-2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50&lt;BR /&gt;.....................................&lt;BR /&gt;173&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Nation&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum all volumes&lt;BR /&gt;&lt;BR /&gt;There are 80 locations and one nation total line. For each quarter, about 800 observations.&lt;BR /&gt;Sometime, a few locations are missing one or two entry_code.&lt;BR /&gt;How can I add the missing observation as &lt;BR /&gt;173&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loc_2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;BR /&gt;&lt;BR /&gt;It will take a long time to visual check the missing observation. &lt;BR /&gt;Sas user supports have any solution for that.&lt;BR /&gt;Thanks in advance for your help.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;WT196838&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 23:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383520#M91471</guid>
      <dc:creator>wtien196838</dc:creator>
      <dc:date>2017-07-27T23:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a missing value to a missing record ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383521#M91472</link>
      <description>&lt;P&gt;Is the variable character or numeric?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's numeric I would expect a missing value to automatically be inserted during the importation; if it's character I would expect it to automatically be an empty string.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 23:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383521#M91472</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-07-27T23:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a missing value to a missing record ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383522#M91473</link>
      <description>&lt;P&gt;What would be the value of the volume for those missing entry codes in the sequence?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 23:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383522#M91473</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-07-27T23:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a missing value to a missing record ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383524#M91475</link>
      <description>&lt;P&gt;That looks like a summary report already. Are you processing anything on the SAS side from what you've shown?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are typically several ways to add missing values into the data. Remember, computers are stupid. If it's not there they can't know it exists unless you tell them somehow. So how do we specify this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. List it out explicitly, this means itemizing the categories/levels you need. This can be done via a format or CLASS DATA. You can search using PRELOADFMT or CLASSDATA to see examples of this.&lt;/P&gt;
&lt;P&gt;2. *IF* all the values are there but not necessarily in the combinations you want you can use the SPARSE option in PROC FREQ.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. If the data is a time component you can use the PROC TIMESERIES to fill in missing data.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 00:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383524#M91475</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-28T00:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a missing value to a missing record ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383532#M91479</link>
      <description>&lt;P&gt;Do you have a list or table of the all 80 locations ?&lt;/P&gt;
&lt;P&gt;Do you expect to have the 4 entry_codes for all locations?&lt;/P&gt;
&lt;P&gt;Assuming you deal now with one quarter only then do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data help;
   set locations;
       retain quarter 173;
       do entry_code = 1 to 4; output; end;
run;

data want;
  merge help have;
  by quarter location entry_code;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jul 2017 01:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383532#M91479</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-28T01:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a missing value to a missing record ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383680#M91538</link>
      <description />
      <pubDate>Fri, 28 Jul 2017 13:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383680#M91538</guid>
      <dc:creator>wtien196838</dc:creator>
      <dc:date>2017-07-28T13:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a missing value to a missing record ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383684#M91541</link>
      <description>Thanks for all solutions.  I explain a little more.  &lt;BR /&gt;Volume column is numeric.  I need to display each location within all entry codes in a report. &lt;BR /&gt;Currently, the report still shows the missing record BUT volume is from previous record, in this example, volume = 200 instead of volume = . (missing). I can not visual check the data since it is up to date report (now is 3 quarters).</description>
      <pubDate>Fri, 28 Jul 2017 13:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383684#M91541</guid>
      <dc:creator>wtien196838</dc:creator>
      <dc:date>2017-07-28T13:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a missing value to a missing record ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383748#M91558</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/41038"&gt;@wtien196838&lt;/a&gt; wrote:&lt;BR /&gt;Thanks for all solutions. I explain a little more. &lt;BR /&gt;Volume column is numeric. I need to display each location within all entry codes in a report. &lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Currently, the report still shows the missing record BUT volume is from previous record, in this example, volume = 200 instead of volume = . (missing).&lt;/STRONG&gt;&lt;/FONT&gt; I can not visual check the data since it is up to date report (now is 3 quarters).&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to explain this a lot more. Post your original data, code to generate the report and what is wrong with it. Otherwise right now we're guessing and going in circles.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 15:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383748#M91558</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-28T15:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a missing value to a missing record ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383959#M91615</link>
      <description>&lt;P&gt;I attached test data and the code as follow:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let Q = 3 ; /* quarter 3 */&lt;/P&gt;
&lt;P&gt;%macro ytd_rollup(infile);&lt;BR /&gt; &lt;BR /&gt;proc sql ;&lt;BR /&gt; create table ytd_temp as&lt;BR /&gt; select loc_id, loc_desc, 100*(var0/volume) as percent format=5.1, volume, qtr&lt;BR /&gt; from &amp;amp;infile.&lt;BR /&gt; group by loc_id, loc_desc, qtr &lt;BR /&gt; union&lt;BR /&gt; select loc_id, loc_desc, 100*(sum(var0)/sum(volume)) as percent format 5.1, sum(volume) as volume , 999 as qtr&lt;BR /&gt; from &amp;amp;infile.&lt;BR /&gt; group by loc_id, loc_desc&lt;BR /&gt; order by loc_id, loc_desc, qtr&lt;BR /&gt; ;&lt;BR /&gt; quit;&lt;/P&gt;
&lt;P&gt;proc sql ;&lt;BR /&gt; create table middle_data as&lt;BR /&gt; select a.*, b.order&lt;BR /&gt; from ytd_temp a&lt;BR /&gt; left join order b&lt;BR /&gt; on a.loc_desc = b.loc_desc ;&lt;BR /&gt; quit;&lt;/P&gt;
&lt;P&gt;proc sort data=middle_data;&lt;BR /&gt; by order qtr ;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;%IF &amp;amp;Q. EQ 2 %THEN %let var_list = Q2_per Q2_vol ;&lt;BR /&gt;%ELSE %IF &amp;amp;Q. EQ 3 %THEN %let var_list = Q2_per Q2_vol Q3_per Q3_vol ;&lt;BR /&gt;%ELSE %IF &amp;amp;Q. EQ 4 %THEN %let var_list = Q2_per Q2_vol Q3_per Q3_vol Q4_per Q4_vol ;&lt;BR /&gt;%ELSE %let var_list = ;&lt;/P&gt;
&lt;P&gt;Data final_data (keep= order loc_desc YTD_per YTD_vol Q1_per Q1_vol &amp;amp;var_list.) ;&lt;BR /&gt; set middle_data;&lt;BR /&gt; by order qtr;&lt;BR /&gt; retain YTD_per YTD_vol Q1_per Q1_vol &amp;amp;var_list. ;&lt;BR /&gt; &lt;BR /&gt; if volume = 0 then volume = . ;&lt;BR /&gt; if percent = 0 then percent = . ;&lt;BR /&gt; select (qtr);&lt;BR /&gt; when (171) do; Q1_per = percent; Q1_vol = volume; end;&lt;BR /&gt; when (172) do; Q2_per = percent; Q2_vol = volume; end;&lt;BR /&gt; when (173) do; Q3_per = percent; Q3_vol = volume; end; &lt;BR /&gt; when (174) do; Q4_per = percent; Q4_vol = volume; end; &lt;BR /&gt; when (999) do; YTD_per = percent; YTD_vol=volume; end;&lt;BR /&gt; otherwise ;&lt;BR /&gt; end;&lt;BR /&gt; if last.order then output;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;%mend ytd_rollup;&lt;/P&gt;
&lt;P&gt;%ytd_rollup(initial_data)&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 23:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/383959#M91615</guid>
      <dc:creator>wtien196838</dc:creator>
      <dc:date>2017-07-28T23:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a missing value to a missing record ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/385021#M92047</link>
      <description>&lt;P&gt;Thanks for all support solutions.&lt;/P&gt;
&lt;P&gt;Based on your suggestions, I resolved my problem.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate your support.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WT196838&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 15:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-missing-value-to-a-missing-record/m-p/385021#M92047</guid>
      <dc:creator>wtien196838</dc:creator>
      <dc:date>2017-08-02T15:46:47Z</dc:date>
    </item>
  </channel>
</rss>

