[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: add new observation
From:       "Chakravarthy, Venky" <Venky.Chakravarthy () PFIZER ! COM>
Date:       2003-06-30 20:03:33
[Download RAW message or body]

Since there are repeats of the "put _infile_", the same solution can be a
bit more aesthetic if wrapped in a do loop:

data _null_ ;
   infile in lrecl = 500 truncover ;
   input ;
   file out ;
   if index(upcase(_infile_),"COMMENT:") then
   do _infile_ = " " , "Comment:________________________" , " " ;
       put _infile_ ;
   end ;
   else put _infile_ ;
run ;

__________________________
Venky Chakravarthy
E-mail: swovcc@hotmail.com

-----Original Message-----
From: Chakravarthy, Venky [mailto:Venky.Chakravarthy@PFIZER.COM]
Sent: Monday, June 30, 2003 3:50 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: add new observation


Strictly if all you want is to add a blank line before and after and expand
the "Comment:" string then the following should do:

filename in "c:\bubble\myforms\temp1.dat" ;
filename out "c:\bubble\myforms\conted0\temp2.dat" ;
data _null_ ;
   infile in lrecl = 500 truncover ;
   input ;
   file out ;
   if index(upcase(_infile_),"COMMENT:") then do ;
      _infile_ = " " ;
      put _infile_ ;
      _infile_ = "COMMENT:________________________" ;
      put _infile_ ;
      _infile_ = " " ;
      put _infile_ ;
   end ;
   else put _infile_ ;
run ;

Kind Regards,
__________________________
Venky Chakravarthy
E-mail: swovcc@hotmail.com

-----Original Message-----
From: Jamil Ibrahim [mailto:jibrahim@IR.UMSMED.EDU]
Sent: Monday, June 30, 2003 3:22 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: add new observation


HI sas users :
I have a data file where I would like to add a new obs every time there
is a var with the value of Comment:
example:
ATA DESCB; **** REMAING QUESTIONS;
INFILE "c:\bubble\myforms\temp1.dat" lrecl=500 MISSOVER pad ;
INPUT @1 DESC1 $CHAR200. @201 desc2 $char200.; desc1=trim(desc1);
if length(desc1) gt 1 ; ***REMOVES BLANK LINES;
 desc1=translate(desc1,"   ", "09"x);
desc2=translate(desc2,"   ", "09"x);
if index(desc1,"Comment:") then do ;

desc1="Comment:____________________________________________________________"

   ;
end;
file "c:\bubble\myforms\conted0\temp2.dat" /* ls=200 dropover */
LS=400;
put @1 desc1 desc2 ;
;

run;

external file example:  temp1.dat
1.    "Destination Joy"  Earnie Larsen, BA, BD, MAR
Obj. 1:  Internalize the principles of a comprehensive program of
recovery into their lives.
Obj. 2:  Construct a personal program of recovery that corresponds to
and encompasses this model.
Comment:
2.     "Sexual Compulsivity:  Assessment & Treatment"  Patsy Fargason,
Ph.D., CAS
Obj. 3:  Differentiate between normal sexual behavior and pathological
sexual behavior.
Obj. 4:  Discuss assessment of the patient with sexual compulsivity.
Comment:
3.    "Professional Sexual Misconduct"  Gary Carr, MD




the output  temp2.dat should look like this:

1.    "Destination Joy"  Earnie Larsen, BA, BD, MAR
Obj. 1:  Internalize the principles of a comprehensive program of
recovery into their lives.
Obj. 2:  Construct a personal program of recovery that corresponds to
and encompasses this model.

Comment:____________________________________________________________________
_

2.     "Sexual Compulsivity:  Assessment & Treatment"  Patsy Fargason,
Ph.D., CAS
Obj. 3:  Differentiate between normal sexual behavior and pathological
sexual behavior.
Obj. 4:  Discuss assessment of the patient with sexual compulsivity.

Comment:____________________________________________________________________
_



3.    "Professional Sexual Misconduct"  Gary Carr, MD



thank you.......


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be
privileged. It is intended for the addressee(s) only. Access to this E-mail
by anyone else is unauthorized. If you are not an addressee, any disclosure
or copying of the contents of this E-mail or any action taken (or not taken)
in reliance on it is unauthorized and may be unlawful. If you are not an
addressee, please inform the sender immediately.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic