Date: Thu, 30 Oct 2003 10:26:53 -0500
Reply-To: "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Subject: Re: Inserting raws in a dataset
Content-Type: text/plain; charset="iso-8859-1"
Franz,
This appears to be a reporting requirement. Investigate the possibility of
using any of the reporting procedures (proc print, proc report etc.) first
before using the below:
data q ;
length var_1 var_2 $5 ;
input var_1 $ var_2 $3-7 ;
cards ;
1 aaaa
1 bbbb
1 cccc
2 dddd
2 eeee
2 fffff
2 gggg
3 hhhh
3 pppp
4 kkkk
run ;
proc sql noprint ;
select count(distinct var_1) into : count
from q ;
quit ;
data w ;
array var_(2) $5 ;
_iorc_ + 1 ;
text = "t_"||put(_iorc_,best.-l) ;
do _n_ = 1 to 2 ;
var_(_n_) = " " ;
end ;
if _iorc_ <= &count. then output ;
text = " " ;
do until (last.var_1) ;
set q ;
by var_1 ;
output ;
end ;
run ;
Good luck.
_________________________________
Venky Chakravarthy
E-mail: swovcc_AT_hotmail_DOT_com
-----Original Message-----
From: Franz [mailto:franz_cl2003@YAHOO.FR]
Sent: Thursday, October 30, 2003 9:54 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Inserting raws in a dataset
Dear all,
Here is the situation I have:
var_1 var_2
1 aaaa
1 bbbb
1 cccc
2 dddd
2 eeee
2 fffff
2 gggg
3 hhhh
3 pppp
4 kkkk
I would like to create a third variable (text)
the following way:
BEFORE the first occurence of a var_1 value
(1,2,3 or 4) I would like to define the value
of the new variable text, so that for the new
observations in the dataset will have missing
values for var_1 and var_2.
var_1 var_2 text
t_1
1 aaaa
1 bbbb
1 cccc
t_2
2 dddd
2 eeee
2 fffff
2 gggg
t_3
3 hhhh
3 pppp
t_4
4 kkkk
Any help?
Many thanks & kind regards,
Franz.
__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/
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.