<?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 check first three observation for a condition in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/check-first-three-observation-for-a-condition/m-p/787043#M10344</link>
    <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;i am trying to check the values present in first 3 rows of an observation for a condition and then put rest of the values in to a new dataset.&lt;/P&gt;&lt;P&gt;can this be done? please help me with this.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Dec 2021 01:58:10 GMT</pubDate>
    <dc:creator>shanti2</dc:creator>
    <dc:date>2021-12-22T01:58:10Z</dc:date>
    <item>
      <title>check first three observation for a condition</title>
      <link>https://communities.sas.com/t5/SAS-Studio/check-first-three-observation-for-a-condition/m-p/787043#M10344</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;i am trying to check the values present in first 3 rows of an observation for a condition and then put rest of the values in to a new dataset.&lt;/P&gt;&lt;P&gt;can this be done? please help me with this.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 01:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/check-first-three-observation-for-a-condition/m-p/787043#M10344</guid>
      <dc:creator>shanti2</dc:creator>
      <dc:date>2021-12-22T01:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: check first three observation for a condition</title>
      <link>https://communities.sas.com/t5/SAS-Studio/check-first-three-observation-for-a-condition/m-p/787049#M10345</link>
      <description>&lt;P&gt;Dataset have observations. Text files have lines.&lt;/P&gt;
&lt;P&gt;It kind of looks like the first three lines in your file have information about the columns and the real data starts on the fourth line.&lt;/P&gt;
&lt;P&gt;Note there is no need to attach a file to show lines of text on this forum.&amp;nbsp; Just use the Insert Code button to paste in the actual lines.&amp;nbsp; Or even easier for us to use to help you paste it as code to recreate the file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
options parmcards=csv;
parmcards4;
 , , rose,jasmine,lily,tulasi
 , ,jan,feb,mar,apr
 , ,23,19,26,30
grp1,india,100,240,140,540
grp1,burma,280,410,390,280
grp1,srilanka,190,381,305,410
grp2,india,100,240,140,540
grp2,burma,280,410,390,280
grp2,srilanka,190,381,305,410
;;;;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can read the information on the first three lines into temporary arrays.&amp;nbsp; You can count how many columns there are while you do that.&amp;nbsp; Then read and write each value as its own observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't say what the numbers in the grid represent so I will just use VALUE as the variable name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  infile csv dsd truncover ;
  length group $5 country $20 col 8 name $30 month $3 day 8 value 8;
  array names [200] $30 _temporary_;
  array months [200] $3 _temporary_;
  array days [200] _temporary_;
  if _n_=1 then do;
     input 2*name @;
     do col=1 to dim(names) until(names[col] = ' ');
       input names[col] @;
     end;
     flowers=col-1;
     retain flowers;
     input / 2*month @;
     do col=1 to flowers;
       input months[col] @;
     end;
     input / 2*day @;
     do col=1 to flowers;
       input days[col] @;
     end;
     input;
  end;
  input group country @;
  do col=1 to flowers;
     name=names[col];
     month=months[col];
     day=days[col];
     input value @;
     output;
  end;
  input;
  drop flowers;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    group    country     col    name       month    day    value

  1    grp1     india        1     rose        jan      23     100
  2    grp1     india        2     jasmine     feb      19     240
  3    grp1     india        3     lily        mar      26     140
  4    grp1     india        4     tulasi      apr      30     540
  5    grp1     burma        1     rose        jan      23     280
  6    grp1     burma        2     jasmine     feb      19     410
  7    grp1     burma        3     lily        mar      26     390
  8    grp1     burma        4     tulasi      apr      30     280
  9    grp1     srilanka     1     rose        jan      23     190
 10    grp1     srilanka     2     jasmine     feb      19     381
 11    grp1     srilanka     3     lily        mar      26     305
 12    grp1     srilanka     4     tulasi      apr      30     410
 13    grp2     india        1     rose        jan      23     100
 14    grp2     india        2     jasmine     feb      19     240
 15    grp2     india        3     lily        mar      26     140
 16    grp2     india        4     tulasi      apr      30     540
 17    grp2     burma        1     rose        jan      23     280
 18    grp2     burma        2     jasmine     feb      19     410
 19    grp2     burma        3     lily        mar      26     390
 20    grp2     burma        4     tulasi      apr      30     280
 21    grp2     srilanka     1     rose        jan      23     190
 22    grp2     srilanka     2     jasmine     feb      19     381
 23    grp2     srilanka     3     lily        mar      26     305
 24    grp2     srilanka     4     tulasi      apr      30     410

&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Dec 2021 02:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/check-first-three-observation-for-a-condition/m-p/787049#M10345</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-22T02:42:42Z</dc:date>
    </item>
  </channel>
</rss>

