All,
Can someone please let me know , What exactly would be the use for using
IN option in data set
For e-g
data vacdata;
length src $1.;
set datasetA (in=in1)
datasetB (in=in2);
if in1 then src='1'; else src='2';
format src $1.;
run;
I was trying to find the documentation , but somehow I am able to see only
for MERGE function, possible please send me the links with details If any
- swamy
|
|
0
|
|
|
|
Reply
|
sasswamy (42)
|
1/21/2010 7:20:36 PM |
|
with that option you can see where the data come from. You know that for
datasetA and for datasetB, but you normally don't know it for vacdata.
In your case you can also see it by obs-number. The first obs are from
datasetA, the rest from datasetB. If you change the order for vacdata or
you have a BY-processing in the data-step, you can see the origin of each
obs in src.
Sometimes important is to be sure that data only come from one of the
datasets. E.g. you want to merge two datasets, but you don't want to add
obs from the right side which are not in the left side (by key for sure):
data res;
merge left (in=inleft) right;
by key;
if inleft;
run;
I use the IN operator very often for that.
Gerhard
On Thu, 21 Jan 2010 14:20:36 -0500, SAS Swamy <sasswamy@GMAIL.COM> wrote:
>All,
>
>Can someone please let me know , What exactly would be the use for using
>IN option in data set
>
>For e-g
>data vacdata;
> length src $1.;
> set datasetA (in=in1)
> datasetB (in=in2);
> if in1 then src='1'; else src='2';
> format src $1.;
>run;
>
>I was trying to find the documentation , but somehow I am able to see only
>for MERGE function, possible please send me the links with details If any
>
>- swamy
|
|
0
|
|
|
|
Reply
|
gerhard.hellriegel (2531)
|
1/21/2010 8:16:15 PM
|
|
Thanks both of you , great help
- swamy
On Thu, Jan 21, 2010 at 3:16 PM, Gerhard Hellriegel <
gerhard.hellriegel@t-online.de> wrote:
> with that option you can see where the data come from. You know that for
> datasetA and for datasetB, but you normally don't know it for vacdata.
> In your case you can also see it by obs-number. The first obs are from
> datasetA, the rest from datasetB. If you change the order for vacdata or
> you have a BY-processing in the data-step, you can see the origin of each
> obs in src.
> Sometimes important is to be sure that data only come from one of the
> datasets. E.g. you want to merge two datasets, but you don't want to add
> obs from the right side which are not in the left side (by key for sure):
>
> data res;
> merge left (in=inleft) right;
> by key;
> if inleft;
> run;
>
> I use the IN operator very often for that.
>
> Gerhard
>
>
>
>
> On Thu, 21 Jan 2010 14:20:36 -0500, SAS Swamy <sasswamy@GMAIL.COM> wrote:
>
> >All,
> >
> >Can someone please let me know , What exactly would be the use for using
> >IN option in data set
> >
> >For e-g
> >data vacdata;
> > length src $1.;
> > set datasetA (in=in1)
> > datasetB (in=in2);
> > if in1 then src='1'; else src='2';
> > format src $1.;
> >run;
> >
> >I was trying to find the documentation , but somehow I am able to see only
> >for MERGE function, possible please send me the links with details If any
> >
> >- swamy
>
|
|
0
|
|
|
|
Reply
|
sasswamy (42)
|
1/21/2010 8:39:30 PM
|
|
Swamy
I'm not certain of the location in the documentation but here's what is going on.
The two variables, in1 and in2, have either the value 0 or 1. If an observation comes from dataseta, in1 = 1 and in2 = 0; if the obs comes from datasetb, then the values are reversed.
In the case of your code, the value of SRC is being set to a character 1 if the obs comes from the first set and '2' if from the second one.
Comments: in1 and in2 exist only during the execution of the particular data step but are not output. Also, in2 is not needed since all of the needed information comes from in1. Note that in2 is never checked.
Hth
Nat Wooding
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of SAS Swamy
Sent: Thursday, January 21, 2010 2:21 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: IN - Option
All,
Can someone please let me know , What exactly would be the use for using
IN option in data set
For e-g
data vacdata;
length src $1.;
set datasetA (in=in1)
datasetB (in=in2);
if in1 then src='1'; else src='2';
format src $1.;
run;
I was trying to find the documentation , but somehow I am able to see only
for MERGE function, possible please send me the links with details If any
- swamy
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.
|
|
0
|
|
|
|
Reply
|
nathaniel.wooding (1453)
|
1/22/2010 12:58:26 PM
|
|
Other example (it only uses one IN= whatever ,you can think about Venn
diagrams to name grups):
data need;
merge sashelp.class (where=(age<=12) in=A)
sashelp.class;
by name;
if A then grup='Younger than 13';
else grup='Older than 12';
run;
Daniel Fernandez.
Barcelona
2010/1/22 Nathaniel Wooding <nathaniel.wooding@dom.com>:
> Swamy
>
> I'm not certain of the location in the documentation but here's what is going on.
>
> The two variables, in1 and in2, have either the value 0 or 1. If an observation comes from dataseta, in1 = 1 and in2 = 0; if the obs comes from datasetb, then the values are reversed.
>
> In the case of your code, the value of SRC is being set to a character 1 if the obs comes from the first set and '2' if from the second one.
>
> Comments: in1 and in2 exist only during the execution of the particular data step but are not output. Also, in2 is not needed since all of the needed information comes from in1. Note that in2 is never checked.
>
> Hth
>
> Nat Wooding
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of SAS Swamy
> Sent: Thursday, January 21, 2010 2:21 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: IN - Option
>
> All,
>
> Can someone please let me know , What exactly would be the use for using
> IN option in data set
>
> For e-g
> data vacdata;
> length src $1.;
> set datasetA (in=in1)
> datasetB (in=in2);
> if in1 then src='1'; else src='2';
> format src $1.;
> run;
>
> I was trying to find the documentation , but somehow I am able to see only
> for MERGE function, possible please send me the links with details If any
>
> - swamy
> CONFIDENTIALITY NOTICE: This electronic message contains
> information which may be legally confidential and or privileged and
> does not in any case represent a firm ENERGY COMMODITY bid or offer
> relating thereto which binds the sender without an additional
> express written confirmation to that effect. The information is
> intended solely for the individual or entity named above and access
> by anyone else is unauthorized. If you are not the intended
> recipient, any disclosure, copying, distribution, or use of the
> contents of this information is prohibited and may be unlawful. If
> you have received this electronic transmission in error, please
> reply immediately to the sender that you have received the message
> in error, and delete it. Thank you.
>
|
|
0
|
|
|
|
Reply
|
fdezdan (222)
|
1/22/2010 7:11:29 PM
|
|
Of course, you can call the temporary variable anything that you like. Personally, I line to use in1, in2, etc., and match the numeric suffix with the numerical order in which I specified the data set.
Doing this, it is a little harder to screw up when I am referencing the variables.
Of course, InA Inb, etc. would work just as well.
Nat
----Original Message-----
From: Daniel Fern�ndez [mailto:fdezdan@gmail.com]
Sent: Friday, January 22, 2010 2:11 PM
To: Nathaniel Wooding (Services - 6)
Cc: SAS-L@listserv.uga.edu
Subject: Re: IN - Option
Other example (it only uses one IN= whatever ,you can think about Venn
diagrams to name grups):
data need;
merge sashelp.class (where=(age<=12) in=A)
sashelp.class;
by name;
if A then grup='Younger than 13';
else grup='Older than 12';
run;
Daniel Fernandez.
Barcelona
2010/1/22 Nathaniel Wooding <nathaniel.wooding@dom.com>:
> Swamy
>
> I'm not certain of the location in the documentation but here's what is going on.
>
> The two variables, in1 and in2, have either the value 0 or 1. If an observation comes from dataseta, in1 = 1 and in2 = 0; if the obs comes from datasetb, then the values are reversed.
>
> In the case of your code, the value of SRC is being set to a character 1 if the obs comes from the first set and '2' if from the second one.
>
> Comments: in1 and in2 exist only during the execution of the particular data step but are not output. Also, in2 is not needed since all of the needed information comes from in1. Note that in2 is never checked.
>
> Hth
>
> Nat Wooding
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of SAS Swamy
> Sent: Thursday, January 21, 2010 2:21 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: IN - Option
>
> All,
>
> Can someone please let me know , What exactly would be the use for using
> IN option in data set
>
> For e-g
> data vacdata;
> length src $1.;
> set datasetA (in=in1)
> datasetB (in=in2);
> if in1 then src='1'; else src='2';
> format src $1.;
> run;
>
> I was trying to find the documentation , but somehow I am able to see only
> for MERGE function, possible please send me the links with details If any
>
> - swamy
> CONFIDENTIALITY NOTICE: This electronic message contains
> information which may be legally confidential and or privileged and
> does not in any case represent a firm ENERGY COMMODITY bid or offer
> relating thereto which binds the sender without an additional
> express written confirmation to that effect. The information is
> intended solely for the individual or entity named above and access
> by anyone else is unauthorized. If you are not the intended
> recipient, any disclosure, copying, distribution, or use of the
> contents of this information is prohibited and may be unlawful. If
> you have received this electronic transmission in error, please
> reply immediately to the sender that you have received the message
> in error, and delete it. Thank you.
>
|
|
0
|
|
|
|
Reply
|
nathaniel.wooding (1453)
|
1/22/2010 7:36:27 PM
|
|
|
5 Replies
134 Views
(page loaded in 0.137 seconds)
|