<?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: Do loop to extract info from multiple consecutive rows. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-extract-info-from-multiple-consecutive-rows/m-p/30638#M5846</link>
    <description>Yes - a looping DO WHILE (&lt;CONDITION&gt;); END;  code paragraph will do the job quite nicely.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument for the SAS.COM support site which has many code samples as well as SAS-hosted DOC:&lt;BR /&gt;
&lt;BR /&gt;
parse multiple data lines input site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Example reference from search results:&lt;BR /&gt;
Using SAS® to Parse External Data&lt;BR /&gt;
Andrew T. Kuligowski, The Nielsen Company&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/forum2008/190-2008.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2008/190-2008.pdf&lt;/A&gt;&lt;/CONDITION&gt;</description>
    <pubDate>Wed, 16 Dec 2009 13:52:32 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-12-16T13:52:32Z</dc:date>
    <item>
      <title>Do loop to extract info from multiple consecutive rows.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-extract-info-from-multiple-consecutive-rows/m-p/30636#M5844</link>
      <description>Hi,&lt;BR /&gt;
I need to build a report about several cognos' cubes (dimensions,&lt;BR /&gt;
levels measures etc..) from *.mdl files (ascii type) then contain the&lt;BR /&gt;
structure.&lt;BR /&gt;
First I import xxxx.mdl file and create variable x, than I exstract&lt;BR /&gt;
cube infos by scan(x, ....), because all infos are key-substring from&lt;BR /&gt;
first collumn. when I meet one key value I know the info is on the&lt;BR /&gt;
next double quoted substring.&lt;BR /&gt;
For example:&lt;BR /&gt;
&lt;BR /&gt;
data stat_cube;&lt;BR /&gt;
 infile &amp;amp;infile truncover;&lt;BR /&gt;
 input x $5000.;&lt;BR /&gt;
 retain name datasource;&lt;BR /&gt;
 length datasource $30.;&lt;BR /&gt;
 if x NE '';&lt;BR /&gt;
 test=scan(x,1);&lt;BR /&gt;
 select (test);&lt;BR /&gt;
          when('Name')       do;&lt;BR /&gt;
                                name=scan(x,2,'"');&lt;BR /&gt;
                                valore=name;&lt;BR /&gt;
                                datasource='';&lt;BR /&gt;
                             end;&lt;BR /&gt;
          when('DataSource') do;&lt;BR /&gt;
                                datasource=scan(x,2,'"');&lt;BR /&gt;
                                valore=datasource;&lt;BR /&gt;
                             end;&lt;BR /&gt;
          when('OrgName')    do;&lt;BR /&gt;
                                orgname=scan(x,2,'"');&lt;BR /&gt;
                                valore=orgname;&lt;BR /&gt;
                             end;&lt;BR /&gt;
          when('Dimension')  do;&lt;BR /&gt;
                                dimension=scan(x,2,'"');&lt;BR /&gt;
                                valore=dimension;&lt;BR /&gt;
                             end;&lt;BR /&gt;
          when('Root')       do;&lt;BR /&gt;
                                root=scan(x,2,'"');&lt;BR /&gt;
                                valore=root;&lt;BR /&gt;
                             end;&lt;BR /&gt;
          when('Levels')     do;&lt;BR /&gt;
                                levels=scan(x,2,'"');&lt;BR /&gt;
                                valore=levels;&lt;BR /&gt;
                             end;&lt;BR /&gt;
          when('Measure')    do; /*** partial code ***/&lt;BR /&gt;
                               measure=scan(x,2,'"');&lt;BR /&gt;
                               valore=measure;&lt;BR /&gt;
                             end;&lt;BR /&gt;
  otherwise delete;&lt;BR /&gt;
 end;&lt;BR /&gt;
 if test='Name' then DataSource='';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Except for 'Measure', every info is on the row where is the key&lt;BR /&gt;
value and the uppuer program retrieve all I need.&lt;BR /&gt;
Sometime for 'Measure' infos are distribuited also on the next rows&lt;BR /&gt;
and, for some strange reason,  cognos could brack it on the successive&lt;BR /&gt;
row.&lt;BR /&gt;
The sample below is from an mdl input file:&lt;BR /&gt;
&lt;BR /&gt;
******* original row data *******&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BLANK line=""&gt;&lt;BR /&gt;
Measure 2687 "Margini" Storage Default OutPutScale 0 Decimals 0&lt;BR /&gt;
ReverseSign False&lt;BR /&gt;
IsCurrency False IsFolder True DrillThrough False EndList&lt;BR /&gt;
&lt;BLANK line=""&gt;&lt;BR /&gt;
Measure 3041 "Var.% Mrg RC vs RP" Label "Var.% Mrg RC vs RP" ShortName&lt;BR /&gt;
"Var.% Mrg RC vs RP"&lt;BR /&gt;
Calc ( "MRG_RAC_RC@2143" - "MRG_RAC_RP@2973" ) / "MRG_RAC_RP@2973"&lt;BR /&gt;
Timing After_Rollup&lt;BR /&gt;
"ShortName"='Var.% Mrg RC vs RP' , "Calc"=( "MRG_RAC_RC@2143" -&lt;BR /&gt;
"MRG_RAC_RP@2973" ) / "MRG_RAC_RP@2973" and "MeasureInfo"="Margine&lt;BR /&gt;
costi / ricavi finanziari progressivo al mese corrente dell'ann"&lt;BR /&gt;
"o precedente." DrillThrough False&lt;BR /&gt;
&lt;BLANK line=""&gt;&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
*******************************&lt;BR /&gt;
&lt;BR /&gt;
For first bloc lines the program meet "Measure" and assign his value&lt;BR /&gt;
at valore=Margini.&lt;BR /&gt;
For the second I nedd estract also "ShortName" =&amp;gt; valore2='Var.% Mrg&lt;BR /&gt;
RC vs RP' , "Calc" =&amp;gt; valore3=( "MRG_RAC_RC@2143" -&lt;BR /&gt;
"MRG_RAC_RP@2973" ) / "MRG_RAC_RP@2973" and "MeasureInfo"="Margine&lt;BR /&gt;
costi / ricavi finanziari progressivo al mese corrente dell'anno&lt;BR /&gt;
precedente."&lt;BR /&gt;
As you can see on the second bloc info for "MeasureInfo" is splitted&lt;BR /&gt;
on 2 consecutive lines.&lt;BR /&gt;
I suppose for read the varius values for "Measure" I must use some do&lt;BR /&gt;
loop (do while(...)) that scan for all lines relative to the "Measure"&lt;BR /&gt;
bloc.&lt;BR /&gt;
Have you any tips about?&lt;BR /&gt;
Thank you in advance.&lt;BR /&gt;
&lt;BR /&gt;
Costas&lt;/BLANK&gt;&lt;/BLANK&gt;&lt;/BLANK&gt;</description>
      <pubDate>Tue, 15 Dec 2009 08:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-extract-info-from-multiple-consecutive-rows/m-p/30636#M5844</guid>
      <dc:creator>Costas</dc:creator>
      <dc:date>2009-12-15T08:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop to extract info from multiple consecutive rows.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-extract-info-from-multiple-consecutive-rows/m-p/30637#M5845</link>
      <description>Hi, no tips about?&lt;BR /&gt;
&lt;BR /&gt;
Costas</description>
      <pubDate>Wed, 16 Dec 2009 08:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-extract-info-from-multiple-consecutive-rows/m-p/30637#M5845</guid>
      <dc:creator>Costas</dc:creator>
      <dc:date>2009-12-16T08:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop to extract info from multiple consecutive rows.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-extract-info-from-multiple-consecutive-rows/m-p/30638#M5846</link>
      <description>Yes - a looping DO WHILE (&lt;CONDITION&gt;); END;  code paragraph will do the job quite nicely.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument for the SAS.COM support site which has many code samples as well as SAS-hosted DOC:&lt;BR /&gt;
&lt;BR /&gt;
parse multiple data lines input site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Example reference from search results:&lt;BR /&gt;
Using SAS® to Parse External Data&lt;BR /&gt;
Andrew T. Kuligowski, The Nielsen Company&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/forum2008/190-2008.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2008/190-2008.pdf&lt;/A&gt;&lt;/CONDITION&gt;</description>
      <pubDate>Wed, 16 Dec 2009 13:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-extract-info-from-multiple-consecutive-rows/m-p/30638#M5846</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-12-16T13:52:32Z</dc:date>
    </item>
  </channel>
</rss>

