sas >> What does colon after equal sign mean?

by gscsrc » Wed, 01 Feb 2006 00:07:48 GMT

if pjwrktyp =:'A' or
pjwrktyp =:'G' or


in the above if statement what does the colon before the 'A' and 'G'
mean how
does it effect the statement?


Thanks!



sas >> What does colon after equal sign mean?

by harry.droogendyk » Wed, 01 Feb 2006 00:12:30 GMT


: means "starts with"

Could also rewrite this statement as: if pjwrktyp in: ('A','G'). Other operators can also be used, eg. >: etc... Can also compare variables, but watch lengths !!

Equivalent SQL syntax is EQT, GTT etc...

-----Original Message-----
From: XXXX@XXXXX.COM
[mailto: XXXX@XXXXX.COM ]On Behalf Of XXXX@XXXXX.COM
Sent: Tuesday, 31 January, 2006 11:08 AM
To: XXXX@XXXXX.COM
Subject: What does colon after equal sign mean?


if pjwrktyp =:'A' or
pjwrktyp =:'G' or


in the above if statement what does the colon before the 'A' and 'G'
mean how
does it effect the statement?


Thanks!
_______________________________________________________________________

This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.

Ce courrier ectronique est confidentiel et prot L'expiteur ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) digns) est interdite.
Si vous recevez ce courrier ectronique par erreur, veuillez m'en aviser immiatement, par retour de courrier ectronique ou par un autre moyen.



sas >> What does colon after equal sign mean?

by yogeshkudale » Wed, 01 Feb 2006 00:18:23 GMT

it means "starts with"

the statement would pick up all the values which start with A or G or ...





Sent by: "SAS(r) Discussion" < XXXX@XXXXX.COM >


To: XXXX@XXXXX.COM
cc:

Our Ref:
Your Ref:
Subject: Whatdoes colon after equal sign mean?

if pjwrktyp =:'A' or
pjwrktyp =:'G' or


in the above if statement what does the colon before the 'A' and 'G'
mean how
does it effect the statement?


Thanks!

-----------------------------------------
******************************************************************
This message originated from the Internet. Its originator may or may
not be who they claim to be and the information contained in the
message and any attachments may or may not be accurate.
******************************************************************




************************************************************
HSBC Electronic Data Processing (India) Private Ltd.
8-2-620/A-E, Babukhan Infotech Chambers, Road No. 10, Banjara Hills,
Hyderabad, India
************************************************************



-----------------------------------------
***********************************************************************
This e-mail is confidential. It may also be legally privileged.
If you are not the addressee you may not copy, forward, disclose
or use any part of it. If you have received this message in error,
please delete it and all copies from your system and notify the
sender immediately by return e-mail.

Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept liability
for any errors or omissions.
***********************************************************************


What does colon after equal sign mean?

by ghellrieg » Wed, 01 Feb 2006 00:21:41 GMT

that means "starts with..."
Including
Avcvcvvc
Abdbebeb
A
A....
...







What does colon after equal sign mean?

by gscsrc » Wed, 01 Feb 2006 01:08:42 GMT

On Tue, 31 Jan 2006 11:21:41 -0500, Gerhard Hellriegel <ghellrieg@T-




Thanks all !

I understand the code now

Greg


What does colon after equal sign mean?

by ghellrieg » Wed, 01 Feb 2006 01:23:42 GMT

By the way, there are other possibilities to get the same. Look at the
following:

data _null_;
set sashelp.class;
where name like "A%";
run;

However the LIKE operator has many other possibilties. "%" stands for all
chars, "_" for a single one

e.g. "_a%c%" means: the second char is a "a" and the rest contains a "c"
anywhere...











What does colon after equal sign mean?

by pchoate » Wed, 01 Feb 2006 02:05:55 GMT

But the colon operator can work between two variables truncating the
longer to length of the shorter during comparison...

If a =: b;


Both of these keep the observation:
data test;
a='a';
aa='aa';
if a=:aa;
run;

data test;
a='a ';
aa='aa';
if trim(a)=:aa;
run;

hth

Paul Choate
DDS Data Extraction
(916) 654-2160

-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On Behalf Of
Gerhard Hellriegel
Sent: Tuesday, January 31, 2006 9:24 AM
To: XXXX@XXXXX.COM
Subject: Re: What does colon after equal sign mean?

By the way, there are other possibilities to get the same. Look at the
following:

data _null_;
set sashelp.class;
where name like "A%";
run;

However the LIKE operator has many other possibilties. "%" stands for
all
chars, "_" for a single one

e.g. "_a%c%" means: the second char is a "a" and the rest contains a "c"
anywhere...





On Tue, 31 Jan 2006 12:08:42 -0500, Greg Curson < XXXX@XXXXX.COM >






What does colon after equal sign mean?

by Mindy » Wed, 01 Feb 2006 03:56:12 GMT

I have the simular question before. The following is one of answers I
got when I posted my question. It explained the question very clearly.

SAS-L could have benefited from a little more context, but I will take
a
stab at this beast. The symbols, =: (also EQ: ) are used in logical
string
comparisons. The strings are compared character by character up to the

length of the shorter string.


proc format ;
value logic
0 = 'FALSE'
1 = 'TRUE';
;
run;
Data test;
a = 'S';
b = 'S0';
c = 'S08';
d = 'SX';
e = 'S08ABC';


format aa bb cc dd ee logic.;
aa = (a =: 'S08');
put "a =: 'S08' is " aa;
bb = (b =: 'S08');
put "b =: 'S08' is " bb;
cc = (c =: 'S08');
put "c =: 'S08' is " cc;
dd = (d =: 'S08');
put "d =: 'S08' is " dd;
ee = (e =: 'S08');
put "e =: 'S08' is " ee;
run;


Hope this helps,


Dan



What does colon after equal sign mean?

by Nathaniel_Wooding » Wed, 01 Feb 2006 04:15:39 GMT

Just to expand on this, as far as I know, the colon modifer will work with
all boolean operators. Additionally, you can use it in many situations that
call for lists such as

drop and keep statements
var statements

but NOT set statements.

Try running the following code

Nat Wooding

data a;
input v1 v2 v3 va4 extravar;
cards;
1 2 3 4 66
5 6 7 8 77 88
9 10 11 12 88
proc print;
var v: ;
run;
proc means;
var v: ;

data b;
set a;
keep v: ;
run;

**** but ***;

data b1 b2 b3;
set a;

data new;
set b: ; * this does not work;
run;



Mindy
<master2005_sas@Y
AHOO.COM> To
Sent by: "SAS(r) XXXX@XXXXX.COM
Discussion" cc
< XXXX@XXXXX.COM
GA.EDU> Subject
Re: What does colon after equal
sign mean?
01/31/2006 02:56
PM


Please respond to
Mindy
<master2005_sas@Y
AHOO.COM>






I have the simular question before. The following is one of answers I
got when I posted my question. It explained the question very clearly.

SAS-L could have benefited from a little more context, but I will take
a
stab at this beast. The symbols, =: (also EQ: ) are used in logical
string
comparisons. The strings are compared character by character up to the

length of the shorter string.


proc format ;
value logic
0 = 'FALSE'
1 = 'TRUE';
;
run;
Data test;
a = 'S';
b = 'S0';
c = 'S08';
d = 'SX';
e = 'S08ABC';


format aa bb cc dd ee logic.;
aa = (a =: 'S08');
put "a =: 'S08' is " aa;
bb = (b =: 'S08');
put "b =: 'S08' is " bb;
cc = (c =: 'S08');
put "c =: 'S08' is " cc;
dd = (d =: 'S08');
put "d =: 'S08' is " dd;
ee = (e =: 'S08');
put "e =: 'S08' is " ee;
run;


Hope this helps,


Dan



-----------------------------------------
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.


What does colon after equal sign mean?

by msz03 » Wed, 01 Feb 2006 04:57:49 GMT

Hi. If you want to know a little more, there's a SUGI paper that describes
nine different uses of the : in SAS...

That Mysterious Colon (:)

http://www2.sas.com/proceedings/sugi26/p073-26.pdf

Mike Zdeb
U@Albany School of Public Health
1 University Drive
Rensselaer, NY 12144-3456
(P)518-402-6479
(F)630-604-1475


What does colon after equal sign mean?

by EvilPettingZoo97 » Wed, 01 Feb 2006 05:06:38 GMT

Though the SQL WHERE clause has available EQT to mimic =: , there is not a
counterpart to in: . However, you can use in: in the FROM clause using the
WHERE data set option if you are not using the pass-through facility or
accessing an SQL view.

Ken

In a message dated 1/31/2006 11:14:55 AM Eastern Standard Time,
XXXX@XXXXX.COM writes:
: means "starts with"

Could also rewrite this statement as: if pjwrktyp in: ('A','G'). Other
operators can also be used, eg. >: etc... Can also compare variables, but watch
lengths !!

Equivalent SQL syntax is EQT, GTT etc...


What does colon after equal sign mean?

by pchoate » Wed, 01 Feb 2006 05:35:07 GMT

Mike -

Nice paper - thanks for the pointer.

Here's another along the same lines by SAS-L illuminati Bill Murphy -

Colonoscopy for the SAS(r) Programmer
http://www2.sas.com/proceedings/sugi29/054-29.pdf

Paul Choate
DDS Data Extraction
(916) 654-2160

-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On Behalf Of
Michael S. Zdeb
Sent: Tuesday, January 31, 2006 12:58 PM
To: XXXX@XXXXX.COM
Subject: Re: What does colon after equal sign mean?

Hi. If you want to know a little more, there's a SUGI paper that
describes
nine different uses of the : in SAS...

That Mysterious Colon (:)

http://www2.sas.com/proceedings/sugi26/p073-26.pdf

Mike Zdeb
U@Albany School of Public Health
1 University Drive
Rensselaer, NY 12144-3456
(P)518-402-6479
(F)630-604-1475


What does colon after equal sign mean?

by nospam » Wed, 01 Feb 2006 06:13:33 GMT

The example is not very general and I think there may have been some
oversimplification.

I'd like to begin with a couple of background points:

1. The operands of a comparison operator are *expressions*. They may happen
to be simple variable names, or constants, but those are special cases.

2. In making character comparisons, SAS automatically ignores trailing
blanks. In other words, it's as if the TRIM function were applied to both
operands.

If the trimmed operands are of sifferent lengths, SAS ordinarily pads the
shorter one with blanks to generate a string having the same length as the
longer one, then procedes with the comparison. Presence of a colon reverses
the rule; that is, the longer value is truncated to the length of the
shorter.

Example:

if compress(pjwrktyp) =: x || y ;

Hard to tell which operand is longer; it can change from observation to
observation. The operator means "begins with" only if it's understood that
it's NOT necessarily that the left operand's value begins with the right
operand's value, but rather that the longer value begins with the shorter.

The colon character has other, totally unrelated, uses in SAS code.





Similar Threads

1. equal sign

2. desh colon -: meant (value?)

On Wed, 22 Aug 2007 05:58:25 -0700,  XXXX@XXXXX.COM  wrote:

>PROC SQL NOPRINT;
>                SELECT  COMPRESS(TRIM(SOURCE),':')
>                        INTO :hostname1
>                %if (&ip_count > 1) %then %do;
>                        -:hostname%left(&ip_count)
>                %end;
>                FROM WORK.tmp;
>        QUIT;
>Please tell me the desh in front of colon meant (value?)
>-:host_name? I guess the difference between :host_name and
>-:host_name?
>
>Thanks,

You've cut this from a macro , and the variable &ip_count either
resolves to 1 or above. If &ip_count is > 1, say 5, then you get
this code generated:

SELECT  COMPRESS(TRIM(SOURCE),':')
             INTO :hostname1-:hostname5

which produces 5 macro variables..

3. desh colon -: meant (value?)

4. sign() equivalent in proc means? - resolved

Thank you Joe.
=20
I was testing with such a small sample data
that I hadn't added the CLASS statement yet.
But indeed in MEANS, the formatted value
does get used in the stat when you use the
CLASS.
=20
Appreciate the tip,
=20
Mark
=20

________________________________

From: Joe Matise [mailto: XXXX@XXXXX.COM ]=20
Sent: Wednesday, March 25, 2009 12:15 PM
To: Terjeson, Mark
Cc:  XXXX@XXXXX.COM 
Subject: Re: sign() equivalent in proc means?



proc format library=3Dwork;
value agef
     low-13 =3D '13 and Under'
    14-15  =3D '14 to 15'
    16-high=3D '16 and Up';
quit;

data have;
set sashelp.class;
format age AGEF.;
run;

proc means data=3Dhave n(age);
class age;
run;

That's the simple sashelp.class version ... it 'just works'.  Nothing
special needed to be done to it.  Then just use output out=3Dtest =
n(age)=3D;
and you get the number of people in each age category.

For example,

proc means data=3Dhave;
class age;
output out=3Dtest n(age)=3D;
run;

I imagine you should just replace AGE with SIGN, and you're okay.
Sometimes the option PRELOADFMT is useful, and also =
ORDER=3D(DATA|FORMAT)
(one or the other) are useful, for causing the order to be different, if
you're using ODS and not outputting to a dataset.  Both are documented
in PROC MEANS documentation.

-Joe


On Wed, Mar 25, 2009 at 1:53 PM, Terjeson, Mark < XXXX@XXXXX.COM >
wrote:


        Interesting, I forgot that some procs can
        evaluate based on the formatted value.
=09
        Background: doing numerous stats against
        one dataset with a fair amount of numeric
        variables.  e.g. N,MIN,P25,MEAN,MEDIAN,P75,MAX
        Doing a proc means is a 4 or 5 line affair
        when using _numeric_. I needed two more stats,
        value>0 and value<=3D0. First, in parallel, I sent
        a plea to SAS-L to pick the brains to see if
        one of the stat modes in proc means could do
        something close, ... while I write a couple of
        many line SQL queries for alllll the individual
        variable names, thus doing it manually. The
        manually written method, of course works, and
        then can also be fed into proc means for a SUM
        and I have the results I need. Was just wondering
        if there was a more concise opportunity.
=09
        Setting a true/false flag via Kevin's format or
        the (sign(xxxx) eq 1) evaluations I did gets
        the job done, and similar to FREQ working on
        format values, I've been checking MEANS doc
        and trying MEANS with format, but no luck so far.
        If it did, then Kevin's idea of a format would be
        really good if MEANS could SUM the formatted value.
=09
        I'm not getting MEANS working yet with formatted
        values and I am not finding any MEANS doc that
        mentions utilizing format values.
=09
        Do you (or anyone else) know if you've used MEANS
        on formatted values?
=09
        Mark
=09


        -----Original Message-----
        From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On
Behalf Of ./
        ADD NAME=3DData _null_;
        Sent: Wednesday, March 25, 2009 11:13 AM
        To:  XXXX@XXXXX.COM 
        Subject: Re: sign() equivalent in proc means?
=09
=09
        Mark, are you trying to count the number of positive and
negative
        values or do you just want to know ALL POSITIVE, ALL NEGATIVE or
BOTH
        +/-.
=09
        As Kevin has suggested you could count them easily by applying a
        FORMAT, untested.
=09
        value sign
        low - <0    =3D  '-1'
        0 =3D '0'
        0< - high =3D'1'
=09
        Then proc freq; tables _numeric_; format _numeric_ sign.;
=09
=09
        If you just wanted to know "all pos/all neg/mixture" then I
think an
        examination of MIN and MAX would reveal that info.
=09
        On 3/25/09, Kevin Viel < XXXX@XXXXX.COM > wrote:
        > On Tue, 24 Mar 2009 14:41:57 -0700, Terjeson, Mark
        < XXXX@XXXXX.COM >
        > wrote:
        >
        > >yeah, I did
        > >            (sign(xxxx) ne 1) as xxxx,
        > >and
        > >            (sign(xxxx) eq 1) as xxxx,
        > >but was hoping one of the stat functions
        > >may get close.
        >
        > Mark,
        >
        >  I hope I understand the problem.  If so, have you considered
a
        format?
        >
        > -Kevin
        >
=09

5. sign() equivalent in proc means?

6. Colon modifer doesn't work for where statement?

Just noticed I can't use colon modifier with "where", but I can
use it with "if". This is for v8.2. Is this a bug fixed in v9, or
it is still the case in v9?


data xx;
abc=2; acv=3; amk=9; output;
abc=1; acv=3; amk=9; output;
run;

data yy;
* set xx (where=(max(abc,acv,amk)=9)); /* this works */
set xx (where=(max(of a:)=9));        /* this does not */
if min(of a:)=1;                       /* this works */
run;

Ya

7. Need help reading raw data file with semi colon delimiter - repost

8. RETAIN statement and name prefix list (colon specification)

Hi.

I am using SAS 8.2 on Windows XP.

I ran a data step with the following two statements:

 keep rootname firstmiss lastmiss allbetween
 miss: ;
 retain    firstmiss lastmiss
 allbetween miss: ;

The KEEP statement managed to place all the variables whose name begins
with "miss" in the output data set.  But the RETAIN statement ignored all
the variables whose names begin with "miss".  When I reran with the
following RETAIN statement everything worked as I expected:

 retain    firstmiss lastmiss
 allbetween miss00 - miss12 ;

I know there was a discussion on SAS-L a couple of years ago about using
the colon name list with the RETAIN statement and finding that the
variables did not enter the data set in the order expected, but I don't
recall seeing that the variables were not retained at all.

Is there a good reason why KEEP works with colon specified name prefix
lists and RETAIN doesn't?

--  TMK  --
"The Macro Klutz"