<?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: New to SAS  - simple problem in other languages - need help in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11129#M1002</link>
    <description>Thank you Tim</description>
    <pubDate>Tue, 03 Nov 2009 22:36:39 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2009-11-03T22:36:39Z</dc:date>
    <item>
      <title>New to SAS  - simple problem in other languages - need help in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11123#M996</link>
      <description>Hi to all of you out there! &lt;BR /&gt;
&lt;BR /&gt;
I need to either 1. update or 2. retrieve erroneous observations of a table (and write them to another table) based on a previously read observation. I have (yet) no clue how I save variables of a previously read observation in a data step. &lt;BR /&gt;
&lt;BR /&gt;
I have here an exampe table which can illustrate the problem I have to solve. There are 3 observations for two products. The prices are stated and the period-intervals where there prices were relevant. Obs. 2 and 5 are erroneous. Why? Well because the valid-from date should be equal to the PREVIOUS valid-to date + 1. There are obviously gaps in 2 and 5. &lt;BR /&gt;
&lt;BR /&gt;
Obs  Product_no    price        valid_from       valid_to &lt;BR /&gt;
1          4711            100        01-01-2000    31-01-2002&lt;BR /&gt;
2          4711            150        15-02-2002    03-06-2008&lt;BR /&gt;
3          4711            125        04-06-2008    31-12-9999&lt;BR /&gt;
4          5000          1500        01-01-2007    31-12-2007&lt;BR /&gt;
5          5000          1575        01-02-2008    31-12-2008&lt;BR /&gt;
6          5000          2000        01-01-2009    31-12-9999&lt;BR /&gt;
&lt;BR /&gt;
(!!! I just saw in a preview of this message that my neetly spaced columns are packed together in the posted version! &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; Therefore: if you think you can help me. please e-mail to menno.hilverdink@sebkort.dk and I'll send you something more clear ...) &lt;BR /&gt;
&lt;BR /&gt;
I need to write a program that can "catch" these entries. Even better a new table which I can later use for update (with PROC SQL for example) that contains the following variables: Product_no,  valid_from, new_valid_from&lt;BR /&gt;
&lt;BR /&gt;
Any of you out there who likes to solve this (for me) riddle? You'd make me a happy man! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers!&lt;BR /&gt;
Menno Hilverdink (Copenhagen, Denmark)</description>
      <pubDate>Tue, 03 Nov 2009 08:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11123#M996</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2009-11-03T08:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS  - simple problem in other languages - need help in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11124#M997</link>
      <description>Using a DATA step approach, one technique would be to create/maintain an "exception" SAS file in addition to your primary SAS data table(s).  The DATA statement can specify more than one output file and use some type of IF/THEN/OUTPUT logic statements to re-direct (your word "catch") observations that do not meet your criteria and send them to a separate table for post-processing of some sort.&lt;BR /&gt;
&lt;BR /&gt;
You will need to decide how to handle the exceptions, for how long to keep them in the exception file, possibly track the number of executions when a particular exception is generated, and produce some exception-reporting, and possibly develop into your application a method of correcting exceptions, if feasible.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Step-by-Step Programming with Base SAS(R) Software - Understanding DATA Step Processing&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304324.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304324.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
SAS(R) 9.2 Language Reference: Concepts - The Data Step&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000992092.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000992092.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
SAS(R) 9.2 Language Reference: Concepts - About DATA Step Execution&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001331122.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001331122.htm&lt;/A&gt;</description>
      <pubDate>Tue, 03 Nov 2009 11:44:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11124#M997</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-11-03T11:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS  - simple problem in other languages - need help in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11125#M998</link>
      <description>In SAS you have several ways to solve this - i.e. have a look at RETAIN or LAG().&lt;BR /&gt;
&lt;BR /&gt;
This little mock-up code will show you one path you could walk down.&lt;BR /&gt;
&lt;BR /&gt;
data input;&lt;BR /&gt;
 format valid_from valid_to ddmmyy10.;&lt;BR /&gt;
 input Obs Product_no price valid_from :ddmmyy10. valid_to :ddmmyy10.;&lt;BR /&gt;
 datalines;&lt;BR /&gt;
1 4711 100 01-01-2000 31-01-2002&lt;BR /&gt;
2 4711 150 15-02-2002 03-06-2008&lt;BR /&gt;
3 4711 125 04-06-2008 31-12-9999&lt;BR /&gt;
4 5000 1500 01-01-2007 31-12-2007&lt;BR /&gt;
5 5000 1575 01-02-2008 31-12-2008&lt;BR /&gt;
6 5000 2000 01-01-2009 31-12-9999&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=input;&lt;BR /&gt;
  by Product_no descending valid_from valid_to;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data output;&lt;BR /&gt;
 format prev new_valid_to ddmmyy10.;&lt;BR /&gt;
 set input;&lt;BR /&gt;
 by Product_no;&lt;BR /&gt;
 if not first.product_no then prev = lag1(valid_from-1);&lt;BR /&gt;
 if prev ne . then new_valid_to = prev;&lt;BR /&gt;
 else new_valid_to = valid_to;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=output;&lt;BR /&gt;
  by Product_no valid_from valid_to;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 03 Nov 2009 11:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11125#M998</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2009-11-03T11:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS  - simple problem in other languages - need help in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11126#M999</link>
      <description>Thanx for your feedback. I will look into it! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
I did solve my problem already like this (with input from a third party): &lt;BR /&gt;
&lt;BR /&gt;
data mylib.erroneous_obs;&lt;BR /&gt;
 set mylib.error_from_date;&lt;BR /&gt;
 by product valid_from_sas; &lt;BR /&gt;
 retain dt 0;&lt;BR /&gt;
    If first.product then do;&lt;BR /&gt;
    dt = valid_to_sas; &lt;BR /&gt;
 end;&lt;BR /&gt;
 else do;&lt;BR /&gt;
    if valid_from_sas ne dt + 1 then do;&lt;BR /&gt;
    new_valid_dt = dt + 1;&lt;BR /&gt;
    output;&lt;BR /&gt;
    end;&lt;BR /&gt;
 dt = valid_to_sas; &lt;BR /&gt;
 end;&lt;BR /&gt;
 format    new_valid_dt     ddmmyyd10.;&lt;BR /&gt;
 drop dt;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Off course the variables name differ ... but surely u can spot the approach. :-)

Message was edited by: Longimanus</description>
      <pubDate>Tue, 03 Nov 2009 12:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11126#M999</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2009-11-03T12:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS  - simple problem in other languages - need help in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11127#M1000</link>
      <description>Menno&lt;BR /&gt;
&lt;BR /&gt;
only in response to:&lt;BR /&gt;
&amp;gt; !! I just saw in a preview of this message that my&lt;BR /&gt;
&amp;gt; neetly spaced columns are packed together in the&lt;BR /&gt;
&amp;gt; posted version! &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; Therefore: if you think you can&lt;BR /&gt;
&amp;gt; help me. please &amp;gt; &lt;BR /&gt;
&lt;BR /&gt;
somewhere among the message history on the forums should exist a guide to support posters who seek "unformatted", allowing a table to keep its shape, and code to keep its indentation.&lt;BR /&gt;
It should describe "tagging". That is preceeding formatted code with {pre} (but using square brackets instead of curly braces), and reinstating normal message formatting with the {/pre]&lt;BR /&gt;
Other message formatting tags I am aware of [b for &lt;B&gt;bold&lt;/B&gt;  [i for &lt;I&gt;italic&lt;/I&gt;[/i &lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
Some helpful poster might be able to provide a link to the range of possibilites, (please someone?)&lt;BR /&gt;
I would really appreciate guidance including what we would need to show the usual symbols rather GE and LE in out code</description>
      <pubDate>Tue, 03 Nov 2009 12:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11127#M1000</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-03T12:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS  - simple problem in other languages - need help in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11128#M1001</link>
      <description>See my post "Forum Markup" in the ODS and Base Reporting forum.</description>
      <pubDate>Tue, 03 Nov 2009 14:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11128#M1001</guid>
      <dc:creator>Tim_SAS</dc:creator>
      <dc:date>2009-11-03T14:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS  - simple problem in other languages - need help in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11129#M1002</link>
      <description>Thank you Tim</description>
      <pubDate>Tue, 03 Nov 2009 22:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-simple-problem-in-other-languages-need-help-in-SAS/m-p/11129#M1002</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-03T22:36:39Z</dc:date>
    </item>
  </channel>
</rss>

