comp.soft-sys.sas - The SAS statistics package.
1. equal sign
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..
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
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
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"