Help using Base SAS procedures

Automatic Sum data

Accepted Solution Solved
Reply
Contributor
Posts: 38
Accepted Solution

Automatic Sum data

Hi,

The table that I am working with contains over 600 metrics that I need to summarize and perform analysis on.

Without manually typing Sum(******)as ******  can this be performed keeping the metric names in source table?

Fred


Accepted Solutions
Solution
‎08-08-2014 02:07 PM
Contributor
Posts: 38

Re: Automatic Sum data

Hi,

I am still getting the Error: A bug in Sas but the proc means is working.

Thanks you for your help.

Fred

View solution in original post


All Replies
Respected Advisor
Posts: 3,799

Re: Automatic Sum data

Posted in reply to fred_major

PROC MEANS

Super User
Posts: 19,833

Re: Automatic Sum data

Posted in reply to fred_major

Yes, use proc means or proc summary NOT proc SQL.

data have;

    array test(100) test1-test100;

    do i=1 to 1000;

    do j=1 to 100;

        test(j)=rand('normal');

    end;

    output;

    end;

    drop i j;

run;

proc means data=have noprint;

var test1-test100;

output out=want sum=;

run;

Respected Advisor
Posts: 3,799

Re: Automatic Sum data

You can even omit the VAR statement to make it "more automatic".

proc means data=have noprint;
  
output out=want sum=;
   run;
Super User
Posts: 19,833

Re: Automatic Sum data

Posted in reply to data_null__

That will include all numeric variables by default.

A lot of our identifiers facility/patient are numeric so I usually want to exclude them from summaries Smiley Happy

Respected Advisor
Posts: 3,799

Re: Automatic Sum data

I think for the most part identifiers "patient numbers" should be character. 

Also for the OP with 600 metrics he may be more inclined to ignore a few sums or drop a few variables with a data set option.  Also depends on what kind of "SAS Variable Lists" the OP can use, he did not mention the var names.

Contributor
Posts: 38

Re: Automatic Sum data

Posted in reply to data_null__

Hi,

I tried this

Proc Means noprint data = results (where =(date >= 2014-08-01 and date = 2014-08-07));

CLASS date;

output out=BM SUM=;

RUN;

I Get

ERROR: A bug in SAS has been encountered. please call your sas rep and report the following.

Error: zaqlopt - option 1003 not supported fro data set

Respected Advisor
Posts: 3,799

Re: Automatic Sum data

Posted in reply to fred_major

date constants in SAS are written 'ddMONyyyy'd where MON is three char abbreviation for month.

Respected Advisor
Posts: 4,927

Re: Automatic Sum data

Posted in reply to fred_major

I have to guess what you really meant in your where condition ... but try this instead:

Proc Means noprint data = results (where =(date >= '01AUG2014'd and date <= '07AUG2014'd));

CLASS date;

output out=BM SUM=;

RUN;

PG

PG
Solution
‎08-08-2014 02:07 PM
Contributor
Posts: 38

Re: Automatic Sum data

Hi,

I am still getting the Error: A bug in Sas but the proc means is working.

Thanks you for your help.

Fred

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 297 views
  • 0 likes
  • 4 in conversation