<?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: Adding same value to variable within groups of rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40190#M8147</link>
    <description>Hello Helle,&lt;BR /&gt;
&lt;BR /&gt;
I do not know you system parameters of course, but it seems to me you underestimate SAS performance. From my experience 33000 rows is nothing to SAS.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
    <pubDate>Mon, 29 Nov 2010 14:38:49 GMT</pubDate>
    <dc:creator>SPR</dc:creator>
    <dc:date>2010-11-29T14:38:49Z</dc:date>
    <item>
      <title>Adding same value to variable within groups of rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40184#M8141</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am importing a txt file into SAS and looking only for rows that contain the four types of text strings below ("date", "ini", "type", "case"). Four rows at a time are related to the same case number.  The challenge is that the order of type and case is not always the same in the text file and so I would like to sort by case number to obtain the same order in all by-groups (and use proc transpose afterwards). I have extracted the case number into a variable of its own so that the data set has two variables: text and caseno.&lt;BR /&gt;
&lt;BR /&gt;
text	caseno&lt;BR /&gt;
date: xxx	.	&lt;BR /&gt;
ini: hli	.&lt;BR /&gt;
type: l	.&lt;BR /&gt;
case: 123	123&lt;BR /&gt;
date: yyy	.		&lt;BR /&gt;
ini: lbj	.&lt;BR /&gt;
case: 587	587&lt;BR /&gt;
type: l	.&lt;BR /&gt;
date: zzz	.	&lt;BR /&gt;
ini: jcg	.&lt;BR /&gt;
type: t	.&lt;BR /&gt;
case: 789	789&lt;BR /&gt;
&lt;BR /&gt;
How can I replace the missing values in caseno with the correct case number? I have experimented with do-loops and the retain statement but somehow cannot figure out how to get it right. &lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Helle</description>
      <pubDate>Fri, 26 Nov 2010 13:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40184#M8141</guid>
      <dc:creator>Helle</dc:creator>
      <dc:date>2010-11-26T13:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Adding same value to variable within groups of rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40185#M8142</link>
      <description>Share what code you have tried that is not working for a most effective response.&lt;BR /&gt;
&lt;BR /&gt;
While inputting your external data, yes, a RETAIN (after performing the proper INPUT logic) will capture / retain the "caseno" value through the input process for related follow-on data-records.&lt;BR /&gt;
&lt;BR /&gt;
But if you must wait until you perform an INPUT for the "next caseno", then you will need to perform an INPUT and also consider testing _INFILE_ before assigning "caseno", so that you can perform an OUTPUT while still having the prior assigned "caseno" variable in your SAS PDV.&lt;BR /&gt;
&lt;BR /&gt;
Encourage the OP to share what SAS code has been attempted, and do so within a SAS-generated log where you COPY/PASTE into a forum reply post here.&lt;BR /&gt;
&lt;BR /&gt;
And, make use of this SAS statement in your DATA step for self-diagnosis to verify that whatever INPUT code you are using is working properly (where using "nn" allows you to insert multiple stmts in your DATA step code for uniqueness):&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG '&amp;gt;DIAG-nn' / _ALL_;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 26 Nov 2010 14:47:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40185#M8142</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-11-26T14:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Adding same value to variable within groups of rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40186#M8143</link>
      <description>Hello Helle,&lt;BR /&gt;
&lt;BR /&gt;
I do not know if it is an optimal solution but it does the trick:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data a;&lt;BR /&gt;
  infile datalines delimiter=':.';&lt;BR /&gt;
  input text $ caseno $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
date: xxx . &lt;BR /&gt;
ini: hli .&lt;BR /&gt;
type: l .&lt;BR /&gt;
case: 123 123&lt;BR /&gt;
date: yyy . &lt;BR /&gt;
ini: lbj .&lt;BR /&gt;
case: 587 587&lt;BR /&gt;
type: l .&lt;BR /&gt;
date: zzz . &lt;BR /&gt;
ini: jcg .&lt;BR /&gt;
type: t .&lt;BR /&gt;
case: 789 789&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
/* Total number of observations */;&lt;BR /&gt;
proc SQL;&lt;BR /&gt;
  select COUNT(*) into :n from a;&lt;BR /&gt;
  %let n=%trim(&amp;amp;n);&lt;BR /&gt;
;quit;&lt;BR /&gt;
%macro a;&lt;BR /&gt;
%local i i1;&lt;BR /&gt;
/* Saves obs by groups of 4 into separate datasets */;&lt;BR /&gt;
%do i=4 %to &amp;amp;n %by 4;&lt;BR /&gt;
   %let i1=%EVAL(&amp;amp;i-3); &lt;BR /&gt;
   data _a&amp;amp;i;&lt;BR /&gt;
     set a;&lt;BR /&gt;
     if &amp;amp;i1 &amp;lt;= _n_ &amp;lt;= &amp;amp;i;&lt;BR /&gt;
   run; &lt;BR /&gt;
   /* Transposes */;&lt;BR /&gt;
   proc sort data=_a&amp;amp;i;&lt;BR /&gt;
     by text;&lt;BR /&gt;
   run;&lt;BR /&gt;
   proc transpose data=_a&amp;amp;i out=_a&amp;amp;i;&lt;BR /&gt;
     var caseno;&lt;BR /&gt;
     id text;&lt;BR /&gt;
   run; &lt;BR /&gt;
   /* Combines transposed into a result */;&lt;BR /&gt;
   %if &amp;amp;i=4 %then %do; data r; set   _a&amp;amp;i; run; %end;&lt;BR /&gt;
   %else          %do; data r; set r _a&amp;amp;i; run; %end;  &lt;BR /&gt;
%end;&lt;BR /&gt;
%mend a;&lt;BR /&gt;
%a;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Fri, 26 Nov 2010 18:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40186#M8143</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-26T18:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Adding same value to variable within groups of rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40187#M8144</link>
      <description>Hi:&lt;BR /&gt;
  In addition to SPR's approach, there is an alternate approach using the RETAIN and the single trailing @ to hold the input line. This method assumes that there are ALWAYS, ALWAYS 4 rows of data for each case. It does not matter what order the data lines are in -- CASE could be first, INI could be first, DATE could be first. But, for this program to work, there must be 4 data lines for each case.&lt;BR /&gt;
 &lt;BR /&gt;
  Basically, the program works because the first 5 characters on each data line determine how the rest of the data line should be read -- whether the line contains a DATE or a TYPE or an INI, etc, etc.&lt;BR /&gt;
 &lt;BR /&gt;
  The whole use of the single trailing @ method of input, allows you to read some of a data line and then "hold" the line while the program decides how to read that line.&lt;BR /&gt;
 &lt;BR /&gt;
  The program below uses the MOD function to create a variable that can be tested in order to conditionally do the output. In the test data, there are 12 datalines, representing 3 cases. If you divide the counter by 4, then with the MOD function, the remainder will be fuzzed to 0 on every 4th dataline. So the final CASEINFO dataset has only 3 observations. IF you want an observation for every case, that is a different program. IF there could EVER be only 3 datalines or 2 datalines for a CASE, that will present a problem for this program. If that is a data possibility, then this program will not work and you would have to code other logic to read the file.&lt;BR /&gt;
 &lt;BR /&gt;
  The program is shown below this post. Also shown is the intermediate SHOWLOGIC output -- that shows how the data values are being retained on every INPUT statement execution and the final CASEINFO file -- which is the one that I think you want to keep and use. On some of your datalines, you showed a '.' -- like a missing value -- I did not bother to read those items, but you can easily change the program to read those if you need to. Also I changed the data to have a real date value instead of xxx, yyy and zzz for date -- since those are character strings and not actually a date.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
*** The program and test data;&lt;BR /&gt;
data caseinfo&lt;BR /&gt;
     showlogic;&lt;BR /&gt;
  length first $5.;&lt;BR /&gt;
  ** retain the variables as they are read;&lt;BR /&gt;
  retain date inival type casechar casenum origord dtext itext ttext ctext;&lt;BR /&gt;
  ** do not think you need dtext, itext, ttext, ctext;&lt;BR /&gt;
                                         &lt;BR /&gt;
  infile datalines dlm=' ';&lt;BR /&gt;
            &lt;BR /&gt;
  ** read the input line and hold it in order to test what type;&lt;BR /&gt;
  ** of data line is being read. Use the first 5 characters on the line;&lt;BR /&gt;
  ** to test how to read the line.;&lt;BR /&gt;
  input @1 first $ @;&lt;BR /&gt;
                         &lt;BR /&gt;
  ** Capture the original order into a variable;&lt;BR /&gt;
  origord = _n_;&lt;BR /&gt;
                        &lt;BR /&gt;
  ** divide the original order by 4 when NUM=0, we have read the 4th;&lt;BR /&gt;
  ** consecutive data line -- this logic assumes that the text file ;&lt;BR /&gt;
  ** ALWAYS has 4 datalines for every case.;&lt;BR /&gt;
  num = mod(origord,4);&lt;BR /&gt;
                                &lt;BR /&gt;
  ** upcase FIRST to control the comparison and not worry about whether;&lt;BR /&gt;
  ** it is mixed case or lower case.;&lt;BR /&gt;
  first = upcase(first);&lt;BR /&gt;
                   &lt;BR /&gt;
  if first =: 'DATE:' then do;&lt;BR /&gt;
     ** read DATE;&lt;BR /&gt;
     input @1 dtext $5. date : mmddyy10. ;&lt;BR /&gt;
  end;&lt;BR /&gt;
  else if first =: 'INI: ' then do;&lt;BR /&gt;
     ** read INIVAL;&lt;BR /&gt;
     input @1 itext $5. inival $  ;&lt;BR /&gt;
  end;&lt;BR /&gt;
  else if first =: 'TYPE:' then do;&lt;BR /&gt;
     ** read TYPE:;&lt;BR /&gt;
     input @1 ttext $5. type $ ;&lt;BR /&gt;
  end;&lt;BR /&gt;
  else if first =: 'CASE:' then do;&lt;BR /&gt;
     ** read CASE as character val and numeric val;&lt;BR /&gt;
     ** not sure why data line had 2 values for case number;&lt;BR /&gt;
     input @1 ctext $5. casechar $ casenum;&lt;BR /&gt;
  end;&lt;BR /&gt;
  output showlogic;&lt;BR /&gt;
  if num = 0 then do;&lt;BR /&gt;
     ** if num=0, then we are on the 4th data row, so now;&lt;BR /&gt;
     ** do an output of all the retained values.;&lt;BR /&gt;
     ** this will result in 1 output for every 4 datalines;&lt;BR /&gt;
     output caseinfo;&lt;BR /&gt;
                  &lt;BR /&gt;
     ** reset the retained variables;&lt;BR /&gt;
     date =.;&lt;BR /&gt;
     casenum =.;&lt;BR /&gt;
     casechar = ' ';&lt;BR /&gt;
     type=' ';&lt;BR /&gt;
      inival = ' ';&lt;BR /&gt;
     dtext = ' ';&lt;BR /&gt;
     itext = ' ';&lt;BR /&gt;
     ttext = ' ';&lt;BR /&gt;
     ctext = ' ';&lt;BR /&gt;
  end;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
date: 11/27/2010 . &lt;BR /&gt;
ini: hli .&lt;BR /&gt;
type: l .&lt;BR /&gt;
case: 123 123&lt;BR /&gt;
date: 11/28/2010 . &lt;BR /&gt;
ini: lbj .&lt;BR /&gt;
case: 587 587&lt;BR /&gt;
type: l .&lt;BR /&gt;
date: 11/29/2010 . &lt;BR /&gt;
ini: jcg .&lt;BR /&gt;
type: t .&lt;BR /&gt;
case: 789 789&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                                 &lt;BR /&gt;
ods listing;&lt;BR /&gt;
options nodate nonumber nocenter ls=120;&lt;BR /&gt;
proc print data=caseinfo;&lt;BR /&gt;
  title 'Final Case file';&lt;BR /&gt;
  var origord num casechar casenum date inival type dtext itext ttext ctext;&lt;BR /&gt;
format date date9.;&lt;BR /&gt;
run;&lt;BR /&gt;
                      &lt;BR /&gt;
proc print data=showlogic;&lt;BR /&gt;
  title 'This file shows logic of using NUM and RETAIN';&lt;BR /&gt;
  title2 'Note how observation is being built by each INPUT stmt';&lt;BR /&gt;
  format date date9.;&lt;BR /&gt;
  var origord num first dtext date itext inival ttext type ctext casechar casenum;&lt;BR /&gt;
run; &lt;BR /&gt;
                      &lt;BR /&gt;
title;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                         &lt;BR /&gt;
The SHOWLOGIC file of 12 observations:&lt;BR /&gt;
[pre]&lt;BR /&gt;
This file shows logic of using NUM and RETAIN&lt;BR /&gt;
Note how observation is being built by each INPUT stmt&lt;BR /&gt;
                   &lt;BR /&gt;
Obs    origord    num    first    dtext         date    itext    inival    ttext    type    ctext    casechar    casenum&lt;BR /&gt;
                                       &lt;BR /&gt;
  1        1       1     DATE:    date:    27NOV2010                                                                 .&lt;BR /&gt;
  2        2       2     INI:     date:    27NOV2010    ini:      hli                                                .&lt;BR /&gt;
  3        3       3     TYPE:    date:    27NOV2010    ini:      hli      type:     l                               .&lt;BR /&gt;
  4        4       0     CASE:    date:    27NOV2010    ini:      hli      type:     l      case:      123         123&lt;BR /&gt;
  5        5       1     DATE:    date:    28NOV2010                                                                 .&lt;BR /&gt;
  6        6       2     INI:     date:    28NOV2010    ini:      lbj                                                .&lt;BR /&gt;
  7        7       3     CASE:    date:    28NOV2010    ini:      lbj                       case:      587         587&lt;BR /&gt;
  8        8       0     TYPE:    date:    28NOV2010    ini:      lbj      type:     l      case:      587         587&lt;BR /&gt;
  9        9       1     DATE:    date:    29NOV2010                                                                 .&lt;BR /&gt;
 10       10       2     INI:     date:    29NOV2010    ini:      jcg                                                .&lt;BR /&gt;
 11       11       3     TYPE:    date:    29NOV2010    ini:      jcg      type:     t                               .&lt;BR /&gt;
 12       12       0     CASE:    date:    29NOV2010    ini:      jcg      type:     t      case:      789         789&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                     &lt;BR /&gt;
The final CASEINFO file of 3 observations:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Final Case file&lt;BR /&gt;
           &lt;BR /&gt;
Obs    origord    num    casechar    casenum         date    inival    type    dtext    itext    ttext    ctext&lt;BR /&gt;
                        &lt;BR /&gt;
 1         4       0       123         123      27NOV2010     hli       l      date:    ini:     type:    case:&lt;BR /&gt;
 2         8       0       587         587      28NOV2010     lbj       l      date:    ini:     type:    case:&lt;BR /&gt;
 3        12       0       789         789      29NOV2010     jcg       t      date:    ini:     type:    case:&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Sat, 27 Nov 2010 19:08:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40187#M8144</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-27T19:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Adding same value to variable within groups of rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40188#M8145</link>
      <description>What your txt file looks like exactly? &lt;BR /&gt;
And what you want dataset to look like?&lt;BR /&gt;
Your data is ambiguous.</description>
      <pubDate>Mon, 29 Nov 2010 09:17:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40188#M8145</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-11-29T09:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: Adding same value to variable within groups of rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40189#M8146</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your input. SPR: I understand the logic of your suggestion but unfortunately processing my more than 33,000 observations in that way made SAS come to a complete standstill. Cynthia: I modified your suggestion and made it work on the dataset that I had already created containing only the four observations per case that I needed. The original txt file had different numbers of rows per case so I had to specifically select strings matching the four categories that I was looking for. &lt;BR /&gt;
&lt;BR /&gt;
Here is the code that I ended up with:&lt;BR /&gt;
data showlogic &lt;BR /&gt;
	caseinfo (keep=dato inival type casechar);&lt;BR /&gt;
	retain dato inival type casechar origord dtext itext ttext ctext;&lt;BR /&gt;
	set cases;&lt;BR /&gt;
	origord = _n_;&lt;BR /&gt;
	num = mod(origord,4);&lt;BR /&gt;
	if text1 =: 'DATE:' then do;&lt;BR /&gt;
		dtext=text1;&lt;BR /&gt;
		dato=text2;&lt;BR /&gt;
	end;&lt;BR /&gt;
	else if text1 =: 'INIT:' then do;&lt;BR /&gt;
     itext=text1;&lt;BR /&gt;
		inival=text2 ;&lt;BR /&gt;
  	end;&lt;BR /&gt;
 	 else if text1 =: 'LOAN:' then do;&lt;BR /&gt;
     ttext=text1;&lt;BR /&gt;
	 type=text2;&lt;BR /&gt;
 	end;&lt;BR /&gt;
 	else if text1 =: 'CASE:' then do;&lt;BR /&gt;
       ctext=text1;&lt;BR /&gt;
		casechar=text2;&lt;BR /&gt;
  	end;&lt;BR /&gt;
  output showlogic;&lt;BR /&gt;
  if num = 0 then do;&lt;BR /&gt;
   output caseinfo;&lt;BR /&gt;
                  &lt;BR /&gt;
     ** reset the retained variables;&lt;BR /&gt;
     dato =.;&lt;BR /&gt;
     casechar = ' ';&lt;BR /&gt;
     type=' ';&lt;BR /&gt;
     inival = ' ';&lt;BR /&gt;
     dtext = ' ';&lt;BR /&gt;
     itext = ' ';&lt;BR /&gt;
     ttext = ' ';&lt;BR /&gt;
     ctext = ' ';&lt;BR /&gt;
  end;&lt;BR /&gt;
return;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
&lt;BR /&gt;
Helle</description>
      <pubDate>Mon, 29 Nov 2010 13:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40189#M8146</guid>
      <dc:creator>Helle</dc:creator>
      <dc:date>2010-11-29T13:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Adding same value to variable within groups of rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40190#M8147</link>
      <description>Hello Helle,&lt;BR /&gt;
&lt;BR /&gt;
I do not know you system parameters of course, but it seems to me you underestimate SAS performance. From my experience 33000 rows is nothing to SAS.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Mon, 29 Nov 2010 14:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40190#M8147</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-29T14:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Adding same value to variable within groups of rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40191#M8148</link>
      <description>...&lt;BR /&gt;
&amp;gt; I am importing a txt file into SAS and looking only&lt;BR /&gt;
&amp;gt; for rows that contain the four types of text strings&lt;BR /&gt;
&amp;gt; below ("date", "ini", "type", "case"). Four rows at a&lt;BR /&gt;
&amp;gt; time are related to the same case number.  The&lt;BR /&gt;
&amp;gt; challenge is that the order of type and case is not&lt;BR /&gt;
&amp;gt; always the same in the text file and so I would like&lt;BR /&gt;
&amp;gt; to sort by case number to obtain the same order in&lt;BR /&gt;
&amp;gt; all by-groups (and use proc transpose afterwards).&lt;BR /&gt;
...&lt;BR /&gt;
If I understand correctly, then you want to read from a text file with only the rows that have all of these four keyword: value pairs. Only the problem is that the orders of type and case change. No problem. Use absolute column pointer controls. Hope this helps a bit.&lt;BR /&gt;
[pre]&lt;BR /&gt;
   data cases;&lt;BR /&gt;
     length date ini type $8;&lt;BR /&gt;
     input @1 @("date:") date $&lt;BR /&gt;
           @1 @("ini:") ini $&lt;BR /&gt;
           @1 @("case:") case&lt;BR /&gt;
           @1 @("type:") type $;&lt;BR /&gt;
     /* all four should not be missing */&lt;BR /&gt;
     if not missing(date) &amp;amp; not missing(ini) &amp;amp; &lt;BR /&gt;
        not missing(case) &amp;amp; not missing(type) then&lt;BR /&gt;
       output;&lt;BR /&gt;
   cards;&lt;BR /&gt;
   date:xxx ini:hli type:l   case:123&lt;BR /&gt;
   date:yyy ini:lbj case:587 type:l&lt;BR /&gt;
   date:zzz ini:jcg type:t   case:789&lt;BR /&gt;
   ;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
   /* check */&lt;BR /&gt;
   proc print data=cases;&lt;BR /&gt;
   run;&lt;BR /&gt;
   /* on log&lt;BR /&gt;
   Obs    date    ini    type    case&lt;BR /&gt;
    1     xxx     hli     l       123&lt;BR /&gt;
    2     yyy     lbj     l       587&lt;BR /&gt;
    3     zzz     jcg     t       789&lt;BR /&gt;
   */&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 07 Dec 2010 20:28:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-same-value-to-variable-within-groups-of-rows/m-p/40191#M8148</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2010-12-07T20:28:40Z</dc:date>
    </item>
  </channel>
</rss>

