Help using Base SAS procedures

Label for the percentile points in PROC UNIVARIATE

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 131
Accepted Solution

Label for the percentile points in PROC UNIVARIATE

Sorry to bother. I used the PROC UNIVARIATE to get the percentiles. The code is:

PROC UNIVARIATE DATA=work.data01 NOPRINT;

  VAR diff;

  OUTPUT OUT=work.pctile01 PCTLPRE=P_ PCTLPTS=1 to 100 BY 1;

RUN;

Note that: the prefix is given as P_.   This made all the percentiles as: P_1, P_2, ... P_10, P_11... P100.

Is there any way that I can make the percentile lables as P_001, P002, P003, ... This made it easier in my case for further data processing.


Accepted Solutions
Solution
‎11-21-2011 09:54 PM
Super User
Posts: 9,681

Re: Label for the percentile points in PROC UNIVARIATE

Maybe you need this:

** Method 1;
PROC UNIVARIATE DATA=sashelp.class NOPRINT;
  VAR age;
  OUTPUT OUT=work.method1 PCTLPRE=P_ PCTLPTS=1 to 100 BY 1;
RUN;

data _null_;
 set sashelp.vcolumn(keep=libname memname name where=(libname='WORK' and memname='METHOD1')) end=last;
 if _n_ eq 1 then call execute('proc datasets library=work nolist; modify method1;rename ');
 count+1;
 call execute(name||'=p_'||strip(put(count,z3.)) );
 if last then call execute(';quit;');
run;


  



Ksharp

View solution in original post


All Replies
SAS Super FREQ
Posts: 8,743

Re: Label for the percentile points in PROC UNIVARIATE

Hi:

  Try the code below. You can get either all P_001, P_002, etc or P001, P002, P003 by just changing the PCTLPRE option.

cynthia

** Method 1;
PROC UNIVARIATE DATA=sashelp.class NOPRINT;
  VAR age;
  OUTPUT OUT=work.method1 PCTLPRE=P_00 PCTLPTS=1 to 100 BY 1;
RUN;

  

proc print data=work.method1;
run;

  

** Method 2;
PROC UNIVARIATE DATA=sashelp.class NOPRINT;
  VAR age;
  OUTPUT OUT=work.method2 PCTLPRE=P00 PCTLPTS=1 to 100 BY 1;
RUN;

  

proc print data=work.method2;
run;

Frequent Contributor
Posts: 131

Re: Label for the percentile points in PROC UNIVARIATE

Thanks for help, Cynthia.

Solution
‎11-21-2011 09:54 PM
Super User
Posts: 9,681

Re: Label for the percentile points in PROC UNIVARIATE

Maybe you need this:

** Method 1;
PROC UNIVARIATE DATA=sashelp.class NOPRINT;
  VAR age;
  OUTPUT OUT=work.method1 PCTLPRE=P_ PCTLPTS=1 to 100 BY 1;
RUN;

data _null_;
 set sashelp.vcolumn(keep=libname memname name where=(libname='WORK' and memname='METHOD1')) end=last;
 if _n_ eq 1 then call execute('proc datasets library=work nolist; modify method1;rename ');
 count+1;
 call execute(name||'=p_'||strip(put(count,z3.)) );
 if last then call execute(';quit;');
run;


  



Ksharp

Frequent Contributor
Posts: 131

Re: Label for the percentile points in PROC UNIVARIATE

I learned from a SAS guru. Good knowledge. Thanks for help Smiley Happy

Valued Guide
Posts: 2,175

Label for the percentile points in PROC UNIVARIATE

bncoxuk

(Cynthia is the guru)

I assume you do not yet use SAS9.3

when you upgrade to SAS9.3 you will find that Cynthia's "method 1" provides exactly what you need, without the overhead of Ksharp's  "call execute()" post processing.

just a matter of time

peterC

Respected Advisor
Posts: 3,777

Re: Label for the percentile points in PROC UNIVARIATE

Peter.C wrote:

bncoxuk

(Cynthia is the guru)


There is no doubt about that!

The OP mentions "further" processing and no matter how "I" look at it the 100 obs is much easer to process than the 100 variables.

proc stdize data=sashelp.class

      out=_null_

      outstat=work.method3

      PCTLPTS=1 to 100 by 1

      ;

   var _numeric_;

   run;

proc print;

   run;

Obs    _TYPE_        Age       Height     Weight

  1    LOCATION    13.3158    62.3368    100.026

  2    SCALE        1.4927     5.1271     22.774

  3    ADD          0.0000     0.0000      0.000

  4    MULT         1.0000     1.0000      1.000

  5    N           19.0000    19.0000     19.000

  6    NObsRead    19.0000    19.0000     19.000

  7    NObsUsed    19.0000    19.0000     19.000

  8    NObsMiss     0.0000     0.0000      0.000

  9    P1          11.0000    51.3000     50.500

10    P2          11.0000    51.3000     50.500

11    P3          11.0000    51.3000     50.500

12    P4          11.0000    51.3000     50.500

13    P5          11.0000    51.3000     50.500

14    P6          11.0000    56.3000     77.000

15    P7          11.0000    56.3000     77.000

16    P8          11.0000    56.3000     77.000

17    P9          11.0000    56.3000     77.000

18    P10         11.0000    56.3000     77.000

19    P11         12.0000    56.5000     83.000

20    P12         12.0000    56.5000     83.000

21    P13         12.0000    56.5000     83.000

22    P14         12.0000    56.5000     83.000

23    P15         12.0000    56.5000     83.000

24    P16         12.0000    57.3000     84.000

25    P17         12.0000    57.3000     84.000

26    P18         12.0000    57.3000     84.000

27    P19         12.0000    57.3000     84.000

28    P20         12.0000    57.3000     84.000

29    P21         12.0000    57.3000     84.000

☑ This topic is SOLVED.

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

Discussion stats
  • 6 replies
  • 1030 views
  • 1 like
  • 5 in conversation