If then Delete OR if then output;

sas

    Sponsored Links

    Next

  • 1. proc means format
    Hello, Suppose I want to compupte the mean of income for each year, each month and each sex. I can get the value by proc means data=test; by year month sex; run; But I would like to have output formatted as year month male female 2006 1 (some number) (some number) 2006 2 (some number) (some numebr) how should I choose the options of proc means? Thank you,
  • 2. taking means only for the positive observations
    Hello, Consider a following dataset. x y z 0 1 0 1 0 1 0 1 0 I would like to take a mean of x,y,z with positive values. Is it possible to write proc means to achieve this goal? Best regards,
  • 3. Need help to generate a decay weighted average
    Hi, I am struggling on the code to generate value Z in the following data set. obs ID X Y Z 1 A 4 3 4 = 4*3/3 2 A 2 5 2.375 = [(4-1)*3 + 2*5]/(3+5) 3 A 1 6 1.214 = [(4-2)*3 + (2-1)*5 + 1*6]/(3+5+6) 4 A 0 0 1 = (4-3)*3/3 5 A 3 9 3 =3*9/9 6 B 5 4 5 =5*4/4 The algorithm is as following: (1) In the first of each group Z = X. So Z(obs 1)=4 and Z(obs 6)=5; (2) Within each group, need to consider two factors from the current obs and from the previous obs. The current factor = X*Y. The previous factor also = X*Y. But X decays by 1 for each obs, and the smallest previous X is zero, no neg. Hence in obs3, we have not only 1*6 from the current obs but also (4-2)*3 from the 1st obs and (2-1)*5 from the second obs. In obs 4, since value of X in obs 2 and obs 3 decays to zero and no current X, we only have a decayed previous factor from 1st obs. I appreciate if someone could help me out. Thanks.
  • 4. print the filename
    Hello, Suppose I have a file helloworld.sas. I would like to print out this filename "helloworld.sas" and the time the file was run to lst file and then export to .csv file. What type of variables or options will help me to do this task? Best regards,
  • 5. rename csv file and save to another folder
    Hi all, I am on a big project now, there are many .csv files in a temp folder, and what I have to do are: 1. pick those csv files which are not empty, i.e., with at least 1 observation 2. rename those files with a variable value in the file, which is an id number 3. save the renamed files to another folder I am totally lost....any help would be highly appreciated! :o) Pooh

Re: If then Delete OR if then output;

Postby nishant.dholakia » Tue, 25 Oct 2005 23:22:13 GMT

I would recommend a where statement instead of an IF because the data would
be subset before going to the PDV in case of a where as opposed to an IF
statement.
 -Nishant



ng a



"its your attitude not your aptitude that determines your altitude"

Re: If then Delete OR if then output;

Postby HERMANS1 » Wed, 26 Oct 2005 00:12:26 GMT

Easwara:
In more extreme cases (>1 million rows of data), I would recommend a SAS
SQL WHERE clause. The SELECT clause will also subset (project) columns.
For 300+K rows of data, assuming that you have relatively short rows, it
won't make much difference whether you use IF or WHERE, or DELETE or
OUTPUT.
Sig

-----Original Message-----
From:  XXXX@XXXXX.COM  [mailto: XXXX@XXXXX.COM ]
On Behalf Of Easwara Moorthy
Sent: Sunday, October 23, 2005 11:18 PM
To:  XXXX@XXXXX.COM 
Subject: If then Delete OR if then output;


Hi All,

I have a situation here with 300+K records I need to filter based on a
rule..for eg if mail=email=phone='Y' then kep it..! any one is having a
'Y', then keep the record.

my question is which will make my computer to breathe at ease when it
filters the records!!

If mail=Y or email=Y or phone=Y then OUTPUT;

(OR)

If mail=N and email=N and phone=N then delete;

i'm not sure which IF statement will give more stress to the PDV/Input
buffer/etc..etc..!!

Thanks
Moorthy

Similar Threads:

1.Deleting the First Row in Text Output

I have the following data located in work.xyz where 'permno' and
'date' are the column headers.

permno  date
10104	20001201
10107	20010321
11081	20010709
11308	20011027
12060	20020214
12490	20020604
13856	20020922

I use the following code to export the data to a text file:

proc export data=xyz
   outfile='C:\xyz.txt'
   replace;
run;

The saved xyz.txt file looks like this:

permno  date
10104	20001201
10107	20010321
11081	20010709
11308	20011027
12060	20020214
12490	20020604
13856	20020922

I need it so the headers permno and date are removed.  I have
attempted to use the if _N_ = 1; then delete command but it does not
work.

Regards,

B.A.

2.to delete or not to delete outliers for extremly skewed variables

hello
i have some extremly skewed variables, if i have to build a predictive
model, should i remove these outliers and made a specific scorecard or
recode them and put them as category or do something else?

3.to delete or not to delete outliers for extremly skewed

Why delete good, meaningful data when you can easily Winsorize?

On 10/21/08, sofiane < XXXX@XXXXX.COM > wrote:
>
> hello
> i have some extremly skewed variables, if i have to build a predictive
> model, should i remove these outliers and made a specific scorecard or
> recode them and put them as category or do something else?
>

4.Suppressing output window but still putting output in a file

Using ODS, I know how to direct the output of proc means to a file,
but I don't know how to prevent that same output from appearing in the
output window.

What I have is something like this:

proc means;
 var x; class y;
 ods output Summary=mean_x_by_y;
run;

There are many values of y, so my output overflows the output window.
I don't need it in the output window, but I do want it in the output
file mean_x_by_y.

Any advice most appreciated....

Thanks!
Paul

5.trouble with GCHART screen output vs file output for transfer to MS Word - with example

Tomislav:

You want to take advantage of the targetdevice= option.  With this
option, you can view the output on the sas screen in whatever alternate
output you like.

If you change the goptions statement as shown below, you can test to the
sas screen and see what you would get in png.  Once it's ready, remove
the targetdevice=png and change the device= back to png.



goptions

device=win
targetdevice=png


gsfname=output

gsfmode=replace

xmax=5in ymax=4in

xpixels=3600 ypixels=2400;


-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On Behalf Of
Tomislav Svoboda
Sent: 10 October, 2004 11:59
To:  XXXX@XXXXX.COM 
Subject: trouble with GCHART screen output vs file output for transfer
to MS Word - with example


Hi,

I am running into problems with the size and proportions of elements in
GCHART outputs using two methods of getting GCHARTs into MS Word (SAS
8.02 ,Windows 2000 and MS Word 2000):

method a) cutting a chart from the SAS output screen and special pasting
it as a device independent bitmap into my Word document.

method b) sending the GCHART output to a PNG file and inserting this
picture file into my Word document.

Here are the problems:
Problem #1) method a) which is the faster method I prefer, is unreliable
- what I see on the output screen is different from what I paste into my
document (y axis label moved and cut off - try example
below)

Problem #2) method b) is more reliable, however, what appears on the
output screen is very different from what appears in the outputted .png
file. Therefore I can only evaluate SAS code changes by opening and
closing insertted .png files.


Can someone please help me either
1) make method a) work, (preferably) or
2) make method b) work such the output I get on the output screen is the
same as what is in my outputted file for faster programming

Here are two samples of code demonstrating the two problems:

Problem #1) what I cut and paste into Word from the following output is
different from the output screen (e.g. y axis label disappears)

data foo;
        input grp $ 18. rate period;
        cards;
Annex,               134.801       1
Annex,               160.158       2
Hostel,              148.788       1
Hostel,              165.126       2
Low Income,Housed    146.350       1
Low Income,Housed    176.528       2
run;

goptions reset=all;

/*I like the SAS output but it doesn't cut and paste as bitmap into Word
well*/

goptions vsize=5 hsize=10;
*goptions ftitle='times new roman/bold' ftext='times new roman' htitle=4
pct hby=4 pct; goptions ftitle='times new roman/bold';
/* Assign pattern characteristics */
pattern v=s c=grey;
/* Assign axis definitions */
axis1 label=none value=(h=12pt f='times new roman' );
axis2 label=(a=90 f='times new roman' h=12pt "Mean Annual Days Under
Community Supervision") value=(h=12pt f='times new roman'); axis3
label=none split="," value=(a=0 h=12pt f='times new roman' );

proc format;
value midform 1='Pre-Annex' 2='Annex';

/* Produce the chart */
proc gchart data = FOO;
vbar Period / sumvar=rate midpoints = 1 2
            maxis=axis1 raxis=axis2 gaxis = axis3 group = grp space =
0.5 gspace = 2 patternid = midpoint width=8 ; format period midform.;
footnote1 ' '; run; quit;



Problem # 2) What appears on the output screen (I don't lke) is
different from the file I insert into Word which is what I want it to
look like:


data foo;
        input grp $ 18. rate period;
        cards;
Annex,               134.801       1
Annex,               160.158       2
Hostel,              148.788       1
Hostel,              165.126       2
Low Income,Housed    146.350       1
Low Income,Housed    176.528       2
run;

goptions reset=all;


*add and subtract this code to send output to screen or file; goptions
device=png gsfname=output gsfmode=replace xmax=5in ymax=4in xpixels=3600
ypixels=2400; filename output 'c:\temp\test.png';

/*good png output, bad SAS screen output*/

goptions vsize=4 hsize=5;
*goptions ftitle='times new roman/bold' ftext='times new roman' htitle=4
pct hby=4 pct; goptions ftitle='times new roman/bold';
/* Assign pattern characteristics */
pattern v=s c=grey;
/* Assign axis definitions */
axis1 label=none value=(h=12pt f='times new roman' );
axis2 label=(a=90 f='times new roman' h=12pt "Mean Annual Days Under
Community Supervision") value=(h=12pt f='times new roman'); axis3
label=none split="," value=(a=0 h=12pt f='times new roman' );

proc format;
value midform 1='Pre-Annex' 2='Annex';


/* Produce the chart */
proc gchart data = FOO;
vbar Period / sumvar=rate midpoints = 1 2
            maxis=axis1 raxis=axis2 gaxis = axis3 group = grp space = 2
gspace = 4 patternid = midpoint width=60 ; format period midform.;
footnote1 ' '; run; quit;




thanks for your help!! And happy Canadian Thanksgiving weekend!

Tomislav

tomislav.svoboda 'at' utoronto.ca

6. OUTPUT option may be preferred over ODS OUTPUT.

7. proc mean output window output in a dataset

8. Output controls output



Return to sas

 

Who is online

Users browsing this forum: No registered users and 34 guest