BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bncoxuk
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

6 REPLIES 6
Cynthia_sas
SAS Super FREQ

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;

bncoxuk
Obsidian | Level 7

Thanks for help, Cynthia.

Ksharp
Super User

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

bncoxuk
Obsidian | Level 7

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

Peter_C
Rhodochrosite | Level 12

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

data_null__
Jade | Level 19

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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