sas >> data

by emanuela » Fri, 13 Jan 2006 03:39:34 GMT

Hi there!
An example of my data file is

Animalid lactation_sequence
1215 1
1215 2
1423 1
1423 2
1423 3

I would like to include in my analysis only the animals that have the
first the second and the third lactation (all three lactations).

can you help me to work this out???
thanks

Manu



sas >> data

by art297 » Fri, 13 Jan 2006 03:49:07 GMT


Manu,

You might be able to use something like the following:

data have;
input Animalid lactation_sequence;
cards;
1215 1
1215 2
1423 1
1423 2
1423 3
9999 3
9999 3
;
run;
proc transpose data=have out=transposed;
by Animalid;
run;
data keepers;
set transposed;
if col1+col2+col3 eq 6;
run;

Art
----------





sas >> data

by tobydunn » Fri, 13 Jan 2006 03:50:41 GMT

emanuela ,

proc sql ;
create table lactation as
select *
from <your data set name here>
group by AnimalId
having max(lactation_sequence ge 3)
Order by AnimalId , Lactation_Sequence ;
quit ;




Toby Dunn





From: emanuela < XXXX@XXXXX.COM >
Reply-To: emanuela < XXXX@XXXXX.COM >
To: XXXX@XXXXX.COM
Subject: data
Date: Thu, 12 Jan 2006 11:39:34 -0800

Hi there!
An example of my data file is

Animalid lactation_sequence
1215 1
1215 2
1423 1
1423 2
1423 3

I would like to include in my analysis only the animals that have the
first the second and the third lactation (all three lactations).

can you help me to work this out???
thanks

Manu


data

by ddiskin » Fri, 13 Jan 2006 03:53:59 GMT

Manu,

data selectid(keep=3DAnimalid);
merge ds(where=3D(lactation_sequence eq 1) in=3D_1)
ds(where=3D(lactation_sequence eq 2) in=3D_2)
ds(where=3D(lactation_sequence eq 2) in=3D_3)
;
by animalid;
if _1 and _2 and _3 and first.animalid;
run;

This gives you a list of all the qualified animals.

data select;
merge selectid(in=3D_in) ds;
by animalid;
if _in;
run;

This gives you all the data for those animals.

HTH,
Dennis Diskin






data

by Jiann-Shiun.Huang » Fri, 13 Jan 2006 04:00:02 GMT

Try the following:

data temp;
input AnimalID $ locationSeq;
cards;
1215 1
1215 2
1423 1
1423 2
1423 3
;
proc sql;
select AnimalID
from temp
group by AnimalID
having max(LocationSeq)=3 and min(LocationSeq)=1 and
Count(LocationSeq)=3;
quit;

J S Huang
1-515-557-3987
fax 1-515-557-2422

Hi there!
An example of my data file is

Animalid lactation_sequence
1215 1
1215 2
1423 1
1423 2
1423 3

I would like to include in my analysis only the animals that have the
first the second and the third lactation (all three lactations).

can you help me to work this out???
thanks

Manu


data

by charles » Fri, 13 Jan 2006 04:09:04 GMT

data tmp;
input Animalid lactation_sequence;
datalines;
1215 1
1215 2
1423 1
1423 2
1423 3
;
run;

proc sql;
create table tmp1 as
select distinct animalid
from tmp
group by animalid
having count(*)=3;
quit;



data

by nospam » Sat, 14 Jan 2006 05:56:28 GMT

I don't know the data. Perhaps it's necessary to inspect for the presence
of all three values, rather than drawing conclusions from the sum or
maximum or the number of observations.

One way to do that is via a self-interleave:

data _123;
set example example(in=pass2);
by animalid;
if first.animalid then do; one = 0; two = 0; three = 0; end;
one + lactation_sequence=1;
two + lactation_sequence=2;
three + lactation_sequence=3;
if pass2 and one and two and three then output;
run;





Data

by adsingh78 » Fri, 13 Jul 2007 22:39:46 GMT

Hi,

I have been trying for figure out how to solve this problem, and so far I
have come up with this.

Data given :

ID(char) Event(char) EG(Num)

201001 Screen 45
201001 Day1 70
201001 Day2 80
201001 Day3 90
201002 Screen 50
201002 Basel 60
201002 Day1 40
201002 Day2 50
201002 Day3 50
201002 Day17 60
201003 Screen 70
201003 Unsch 50
201003 Day1 60
201003 Day2 40
201003 Day17 50

Output should be like this:

ID(char) Event(char) EG(Num) Eg_B(num) EGB(=EG-Eg_b)

201001 Screen 45 45 .
201001 Day1 70 45 25
201001 Day2 80 45 35
201001 Day3 90 45 45

201002 Screen 50 60 .
201002 Basel 60 60 .
201002 Day1 40 60 -20
201002 Day2 50 60 -10
201002 Day3 50 60 -10
201002 Day17 60 60 0

201003 Screen 70 50 .
201003 Unsch 50 50 .
201003 Day1 60 50 10
201003 Day2 40 50 -10
201003 Day17 50 50


NOTE: Eg_B should be last value before Day1.

I tried something like this but not getting what I want:

data test;
set test;
by ID;
retain EG_B;
attrib EG_B length=3 format=3. ;
_EG=lag(EG);
if Event='DAY 1' then EG_B=_EG;
if first.id then EG_B=.;
run;
proc sql;
select count(*) into: nobs from &prognm;
quit;

data test(drop=_EG i) ;
set test;
attrib EGB length=3 ;
do i= 1 to &nobs;
if _n_=i and EG_B=. then EG_B=EG;
end;
EGB=EG-EG_B;
run;


Thanks in advance,

DP


Data

by tobydunn » Fri, 13 Jul 2007 22:51:43 GMT

Have some sort of rules by which you wsih to use to egenrate these numbers.



Toby Dunn

If anything simply cannot go wrong, it will anyway. Murphys Law #2.

The buddy system is essential to your survival; it gives the enemy somebody
else to shoot at.
Murphys Law #


Tell a man there are 300 billion stars in the universe and he'll believe
you. Tell him a bench has wet paint on it and he'll have to touch to be
sure. Murphys Law #9






From: DP < XXXX@XXXXX.COM >
Reply-To: DP < XXXX@XXXXX.COM >
To: XXXX@XXXXX.COM
Subject: Data
Date: Fri, 13 Jul 2007 10:39:46 -0400

Hi,

I have been trying for figure out how to solve this problem, and so far I
have come up with this.

Data given :

ID(char) Event(char) EG(Num)

201001 Screen 45
201001 Day1 70
201001 Day2 80
201001 Day3 90
201002 Screen 50
201002 Basel 60
201002 Day1 40
201002 Day2 50
201002 Day3 50
201002 Day17 60
201003 Screen 70
201003 Unsch 50
201003 Day1 60
201003 Day2 40
201003 Day17 50

Output should be like this:

ID(char) Event(char) EG(Num) Eg_B(num) EGB(=EG-Eg_b)

201001 Screen 45 45 .
201001 Day1 70 45 25
201001 Day2 80 45 35
201001 Day3 90 45 45

201002 Screen 50 60 .
201002 Basel 60 60 .
201002 Day1 40 60 -20
201002 Day2 50 60 -10
201002 Day3 50 60 -10
201002 Day17 60 60 0

201003 Screen 70 50 .
201003 Unsch 50 50 .
201003 Day1 60 50 10
201003 Day2 40 50 -10
201003 Day17 50 50


NOTE: Eg_B should be last value before Day1.

I tried something like this but not getting what I want:

data test;
set test;
by ID;
retain EG_B;
attrib EG_B length=3 format=3. ;
_EG=lag(EG);
if Event='DAY 1' then EG_B=_EG;
if first.id then EG_B=.;
run;
proc sql;
select count(*) into: nobs from &prognm;
quit;

data test(drop=_EG i) ;
set test;
attrib EGB length=3 ;
do i= 1 to &nobs;
if _n_=i and EG_B=. then EG_B=EG;
end;
EGB=EG-EG_B;
run;


Thanks in advance,

DP

_________________________________________________________________
Need a brain boost? Recharge with a stimulating game. Play now!
http://club.live.com/home.aspx?icid=club_hotmailtextlink1


Data

by diddy1512 » Fri, 13 Jul 2007 23:06:16 GMT

Hi,

if your data is already sorted in the way you presented than maybe the code below could help you:

data eg;
input ID $ Event $ Eg;
datalines ;
201001 Screen 45
201001 Day1 70
201001 Day2 80
201001 Day3 90
201002 Screen 50
201002 Basel 60
201002 Day1 40
201002 Day2 50
201002 Day3 50
201002 Day17 60
201003 Screen 70
201003 Unsch 50
201003 Day1 60
201003 Day2 40
201003 Day17 50
;
run;


data eg_b(keep=id Eg_B);
set eg;
by id;
eg_b=lag(eg);
if event='Day1' then output;
run;
data eg;
merge eg eg_b;
by id;
EGB=EG-Eg_b;
run;

Best regards,

Ovidiu






Toby Dunn

If anything simply cannot go wrong, it will anyway. Murphys Law #2.

The buddy system is essential to your survival; it gives the enemy somebody
else to shoot at.
Murphys Law #


Tell a man there are 300 billion stars in the universe and he'll believe
you. Tell him a bench has wet paint on it and he'll have to touch to be
sure. Murphys Law #9






From: DP
Reply-To: DP
To: XXXX@XXXXX.COM
Subject: Data
Date: Fri, 13 Jul 2007 10:39:46 -0400

Hi,

I have been trying for figure out how to solve this problem, and so far I
have come up with this.

Data given :

ID(char) Event(char) EG(Num)

201001 Screen 45
201001 Day1 70
201001 Day2 80
201001 Day3 90
201002 Screen 50
201002 Basel 60
201002 Day1 40
201002 Day2 50
201002 Day3 50
201002 Day17 60
201003 Screen 70
201003 Unsch 50
201003 Day1 60
201003 Day2 40
201003 Day17 50

Output should be like this:

ID(char) Event(char) EG(Num) Eg_B(num) EGB(=EG-Eg_b)

201001 Screen 45 45 .
201001 Day1 70 45 25
201001 Day2 80 45 35
201001 Day3 90 45 45

201002 Screen 50 60 .
201002 Basel 60 60 .
201002 Day1 40 60 -20
201002 Day2 50 60 -10
201002 Day3 50 60 -10
201002 Day17 60 60 0

201003 Screen 70 50 .
201003 Unsch 50 50 .
201003 Day1 60 50 10
201003 Day2 40 50 -10
201003 Day17 50 50


NOTE: Eg_B should be last value before Day1.

I tried something like this but not getting what I want:

data test;
set test;
by ID;
retain EG_B;
attrib EG_B length=3 format=3. ;
_EG=lag(EG);
if Event='DAY 1' then EG_B=_EG;
if first.id then EG_B=.;
run;
proc sql;
select count(*) into: nobs from &prognm;
quit;

data test(drop=_EG i) ;
set test;
attrib EGB length=3 ;
do i= 1 to &nobs;
if _n_=i and EG_B=. then EG_B=EG;
end;
EGB=EG-EG_B;
run;


Thanks in advance,

DP

_________________________________________________________________
Need a brain boost? Recharge with a stimulating game. Play now!
http://club.live.com/home.aspx?icid=club_hotmailtextlink1



---------------------------------
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.


Data

by Nathaniel.Wooding » Fri, 13 Jul 2007 23:19:15 GMT

P

The following obeys the criterion that eg_b be the last event before the
days start.



Data a;
informat ID Event $6.;
input ID Event EG;
cards;
201001 Screen 45
201001 Day1 70
201001 Day2 80
201001 Day3 90
201002 Screen 50
201002 Basel 60
201002 Day1 40
201002 Day2 50
201002 Day3 50
201002 Day17 60
201003 Screen 70
201003 Unsch 50
201003 Day1 60
201003 Day2 40
201003 Day17 50
run;

Data b (rename=(eg = eg_b)) ;* capture the last eg before the Day events
start;
set a (where=(event ne:'D'));
by id ;
if last.id;
keep id eg;
run;

Data b;
merge a b;
by id;
if event ne:'D' then egb=.;
else egb=eg-eg_b;
run;
Proc print;
run;




Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977



DP
<adsingh78@GMAIL.
COM> To
Sent by: "SAS(r) XXXX@XXXXX.COM
Discussion" cc
< XXXX@XXXXX.COM
GA.EDU> Subject
Data

07/13/2007 10:39
AM


Please respond to
DP
<adsingh78@GMAIL.
COM>






Hi,

I have been trying for figure out how to solve this problem, and so far I
have come up with this.

Data given :

ID(char) Event(char) EG(Num)

201001 Screen 45
201001 Day1 70
201001 Day2 80
201001 Day3 90
201002 Screen 50
201002 Basel 60
201002 Day1 40
201002 Day2 50
201002 Day3 50
201002 Day17 60
201003 Screen 70
201003 Unsch 50
201003 Day1 60
201003 Day2 40
201003 Day17 50

Output should be like this:

ID(char) Event(char) EG(Num) Eg_B(num) EGB(=EG-Eg_b)

201001 Screen 45 45 .
201001 Day1 70 45 25
201001 Day2 80 45 35
201001 Day3 90 45 45

201002 Screen 50 60 .
201002 Basel 60 60 .
201002 Day1 40 60 -20
201002 Day2 50 60 -10
201002 Day3 50 60 -10
201002 Day17 60 60 0

201003 Screen 70 50 .
201003 Unsch 50 50 .
201003 Day1 60 50 10
201003 Day2 40

Data

by adsingh78 » Fri, 13 Jul 2007 23:27:56 GMT

I have added rules to my message so that it makes more sense.

Hi,

I have been trying for figure out how to solve this problem, and so far I
have come up with this.

Data given :

ID(char) VIS Event(char) EG(Num)

201001 10 Screen 45
201001 30 Day1 70
201001 40 Day2 80
201001 50 Day3 90
201002 10 Screen 50
201002 20 Basel 60
201002 30 Day1 40
201002 40 Day2 50
201002 50 Day3 50
201002 140 Day17 60
201003 10 Screen 70
201003 25 Unsch 50
201003 30 Day1 60
201003 40 Day2 40
201003 50 Day17 50

Output should be like this:

ID(char) VIS Event(char) EG(Num) Eg_B(num) EGB(=EG-Eg_b)

201001 10 Screen 45 45 .
201001 30 Day1 70 45 25
201001 40 Day2 80 45 35
201001 50 Day3 90 45 45

201002 10 Screen 50 60 .
201002 20 Basel 60 60 .
201002 30 Day1 40 60 -20
201002 40 Day2 50 60 -10
201002 50 Day3 50 60 -10
201002 140 Day17 60 60 0

201003 10 Screen 70 50 .
201003 25 Unsch 50 50 .
201003 30 Day1 60 50 10
201003 40 Day2 40 50 -10
201003 140 Day17 50 50 .


RULES: 1. Eg_B should be last value before Day1 by ID.
2. EGB should be missing for any value(s) before Day1.


I tried something like this but not getting what I want:

data test;
set test;
by ID;
retain EG_B;
attrib EG_B length=3 format=3. ;
_EG=lag(EG);
if Event='DAY 1' then EG_B=_EG;
if first.id then EG_B=.;
run;
proc sql;
select count(*) into: nobs from &prognm;
quit;

data test(drop=_EG i) ;
set test;
attrib EGB length=3 ;
do i= 1 to &nobs;
if _n_=i and EG_B=. then EG_B=EG;
end;
EGB=EG-EG_B;
run;


Thanks in advance,

DP


Data

by nospam » Sun, 15 Jul 2007 03:36:47 GMT

n Fri, 13 Jul 2007 10:39:46 -0400, DP < XXXX@XXXXX.COM > wrote:


A one-step solution can be accomplished with the Double DoW structure.

Test data:

Data a;
informat ID Event $6.;
input
ID Event EG
; cards;
201001 Screen 45
201001 Day1 70
201001 Day2 80
201001 Day3 90
201002 Screen 50
201002 Basel 60
201002 Day1 40
201002 Day2 50
201002 Day3 50
201002 Day17 60
201003 Screen 70
201003 Unsch 50
201003 Day1 60
201003 Day2 40
201003 Day17 50
999999 Screen 45
999999 Day2 80
999999 Day3 90

;

Notice that I've added a case where there is no Day1 observation. That makes
the data set stronger for testing purposes.

Here's the code:

Data b(drop = counter Day1);
do counter = 1 by 1 until (last.id);
set a;
by id;
if event='Day1' then Day1 = counter;
if missing(Day1) then EG_B = eg;
end;
*; if missing(Day1) then EG_B = . ;
do counter = 1 to counter;
set a;
by id;
if counter >= Day1 then EGB = eg - eg_b;
output;
end;
run;

A curiosity: there are two seemingly contradictory statements:

if missing(Day1) then EG_B = eg;
if missing(Day1) then EG_B = . ;

Of course the contexts are different and both are appropriate.

Result:

ID Event EG EG_B EGB

201001 Screen 45 45 .
201001 Day1 70 45 25
201001 Day2 80 45 35
201001 Day3 90 45 45
201002 Screen 50 60 .
201002 Basel 60 60 .
201002 Day1 40 60 -20
201002 Day2 50 60 -10
201002 Day3 50 60 -10
201002 Day17 60 60 0
201003 Screen 70 50 .
201003 Unsch 50 50 .
201003 Day1 60 50 10
201003 Day2 40 50 -10
201003 Day17 50 50 0
999999 Screen 45 . .
999999 Day2 80 . .
999999 Day3 90 . .


Data

by gaojihuiyuan » Fri, 23 May 2008 21:36:29 GMT

Data.org - Debt, AIDS, Trade, Africa
Join Bono to help Africa through DATA.org - Debt, AIDS, Trade, Africa.
Learn what actions you can take to help save Africa. Sign up for
action e-mails and join D. A. T. A.
http://www.healthhuman.com.cn/Data.htm

Verizon Business Data Internet Security
Don't pay more for added bandwidth. Get a free consultation today.
http://www.healthhuman.com.cn/Data.htm

Latest Stock Data at Buyins.net
Find the short squeeze price for your stock before you buy or sell at
buyins.net. Get real time squeeze trigger data. Squeeze trigger finds
short squeezes in 15,000 U.S. stocks in real time.
http://www.healthhuman.com.cn/Data.htm


data

by raviksas » Mon, 23 Feb 2009 22:11:47 GMT

where can i find credit card datasets to analysis?


Similar Threads

1. Data Entry Online, Data Format, Data Conversion and Data Entry Services through Data Entry Outsourcing

2. Save 60% on Data Entry, Data Conversion, Data Processing Services by Offshore-Data-Entry

3. Advantages of Data Conversion and Data Formats Services by Data Entry India

4. Sample 26140: Creating a new data set for each BY-Group in a data

5. SPSS data file to SAS data file: only partial variable labels

Dear fellow SAS users:


I am trying to convert an SPSS data file (.sav, not .por) to SAS, using
SPSS version 15 for Windows. The data file is large, but not huge (176
cases, 963 variables). I have SAS 9.1.3 on Windows XP.
I used the following commands, and got the Warning message that "excess
labels will be omitted." (See below) SPSS successfully copied over the
variable labels for the first 2/3 of the variables, but then just stopped.
The wording of the message ("cumulative length of the variable labels
exceeds the limitations of the target file type") suggests that there is
some limitation of memory size involved.
Incidentally, I did succeed in getting the value labels captured in a
separate file containing SAS statements.
So the question is: Is there any way I can increase a default memory or
buffer size to allow SPSS to copy all the variable labels?

Thanks for any suggestions.

Sincerely,
Joe Hoffman

Here's my code and message:

get file = 'G:\q556\data\Master_file\master.sav'.
SAVE TRANSLATE OUTFILE='G:\q556\data\Master_file\master.sas7bdat'
  /TYPE=SAS /VERSION=7 /PLATFORM=WINDOWS /MAP /REPLACE
  /VALFILE='G:\q556\data\Master_file\master.sas' .

>Warning # 9077
>The cumulative length of the variable labels exceeds the limitations of
the target file type.  The excess labels will be omitted.

Data written to G:\q556\data\Master_file\master.sas7bdat.
963 variables and 176 cases written.
Variable: ID                 Type: Number   Width:  12   Dec: 0
Variable: SIA1               Type: Number   Width:   3   Dec: 0
. . . . .
==============================================
Joseph H Hoffman
Data Analyst
Research Institute on Addictions
State University of New York at Buffalo
1021 Main Street
Buffalo NY 14203
phone 716-887-2219
FAX 716-887-2510
e-mail   XXXX@XXXXX.COM 
==============================================

6. Update info in data set based on other data set

7. Complex DATA step problem with longitudinal data

Hello

With my trusty copy of Ron Cody's Longitudinal Data and SAS, I've been able to solve most of my DATA step problems.  But now I've got one that even Ron doesn't cover.

I've got data like this
FullName        Date          GDS
ADOLPH A    06/25/1980    2
ADOLPH A    10/22/1980    2
ADOLPH B    10/17/1984    2
ADOLPH B    07/16/1981    2
ADOLPH B    01/16/1985    2
AILEEN A    08/11/1982    2
AILEEN A    08/11/1987    2
AILEEN A    01/01/1999    4
AL     B    04/10/1980    2
AL     B    06/04/1980    1
AL     B    02/29/1984    1
AL     B    11/03/1987    3
AL     B    04/24/1994    3
ALCENIA A   10/24/1989    2
ALCENIA A   07/17/1990    2
ARTHUR  C   04/10/1985    2
ARTHUR  C    04/26/1988    3
ARTHUR  C    02/27/1991    2



with many more variables and 77 people (the data has a real full name, I've used fake last initials for privacy concerns).  Originally, I wanted to create datasets FIRST and LAST, with the first and last observation for each person, and the book has the solution.

data new;
 set old;
  by fullname dot;
 if first.fullname and last.fullname then delete;
 if first.fullname then output gds.forbobfirst;
 if last.fullname then output gds.forboblast;
run;

But now, I want something more complex:

If GDS stays the same, the interval has to be at least 5 years.
If GDS changes the interval has to be at most 7 years.
If GDS gets higher, and then lower, don't include the one that was higher

Within those parameters, pick the first and last sessions.....

so

AILEEN A  08/11/1982    2
AILEEN A  08/11/1987    2
AL     B  02/29/1984    1
AL     B  11/03/1987    3
ARTHUR C  04/10/1985    2
ARTHUR C  02/27/1991    2


This is way beyond me.....

Thanks in advance, as always

(oh, and I have access to this data only on Monday, Tuesday and Wednesday, so I may not be able to respond fully on some queries until Monday).

Peter




Peter L. Flom, PhD
Statistical Consultant
www DOT peterflom DOT com

8. Save 60% on Data Entry, Data Conversion,