Help using Base SAS procedures

proc freq

Accepted Solution Solved
Reply
Super Contributor
Posts: 266
Accepted Solution

proc freq

data test;

input empno ename$ job$ sal deptno;

datalines;

7788   SCOTT        ANALYST     3000.00 20

7902   FORD         ANALYST     3000.00 20

7934   MILLER       CLERK       1300.00 10

7369   SMITH        CLERK       800.00  20

7876   ADAMS        CLERK       1100.00 20

7900   JAMES        CLERK       950.00  30

7782   CLARK        MANAGER     2450.00 10

7566   JONES        MANAGER     2975.00 20

7698   BLAKE        MANAGER     2850.00 30

7839   KING         PRESIDENT   5000.00 10

7499   ALLEN        SALESMAN    1600.00 30

7521   WARD         SALESMAN    1250.00 30

7654   MARTIN       SALESMAN    1250.00 30

7844   TURNER       SALESMAN    1500.00 30

;

run;

proc print; run;

proc sort data=test; by deptno; run;

proc freq data=test;

table job/nocum nopercent;

by deptno;

weight sal;

run;

Hi, Can we change the level of column frequency in the result of this programme of can we create a new dataset same as result????

thanks


Accepted Solutions
Solution
‎01-30-2013 01:00 AM
Trusted Advisor
Posts: 1,137

Re: proc freq

Hi,

Another way to get the output dataset

please try the below code, here work.freq is the location of the dataset freq in the work library and the per your request frequency is renamed as sum_sal.

ods listing close;

ods output onewayfreqs=work.freq(drop=f_job table rename=(frequency=sum_sal));

proc freq data=test;

table job/nocum nopercent;

by deptno;

weight sal;

run;

ods output close;

ods listing;

Thanks,

Jagadish

Thanks,
Jag

View solution in original post


All Replies
Trusted Advisor
Posts: 1,909

Re: proc freq

Can we change the level of column frequency

Explain further, or better yet, give an example of what you want

Super Contributor
Posts: 266

Re: proc freq

Posted in reply to PaigeMiller

OUTPUT result of given code.                       Desired OUTPUT ...

------- deptno=10 -----                                   ------- deptno=10 -----

job               Frequency                               job              SUM_SAL

CLERK           1300                                  CLERK           1300

MANAGER      2450                                 MANAGER      2450

PRESIDEN      500                                   PRESIDEN      500

----- deptno=20 --------                               ------ deptno=20 ---------

job        Frequency                                    job        SUM_SAL

ANALYST        6000                                  ANALYST        6000

CLERK          1900                                   CLERK          1900

MANAGER        2975                              MANAGER        2975

--------------so on....like for deptno=30 -------         -------so on....like for deptno=30

and to store it as a dataset like.

deptno     job               sum_sal

10           CLERK           1300                                 

20           MANAGER      2450                               

30           PRESIDEN      500

so can we change the label of column name frequency as like sum_sal

Solution
‎01-30-2013 01:00 AM
Trusted Advisor
Posts: 1,137

Re: proc freq

Hi,

Another way to get the output dataset

please try the below code, here work.freq is the location of the dataset freq in the work library and the per your request frequency is renamed as sum_sal.

ods listing close;

ods output onewayfreqs=work.freq(drop=f_job table rename=(frequency=sum_sal));

proc freq data=test;

table job/nocum nopercent;

by deptno;

weight sal;

run;

ods output close;

ods listing;

Thanks,

Jagadish

Thanks,
Jag
Super Contributor
Posts: 266

Re: proc freq

Posted in reply to PaigeMiller

sorry i wrote level ,, i meant label... i want to change the label name of freq column name.

Regular Contributor
Posts: 195

Re: proc freq

Hi Aman.

I think it quiet easy, you need to manipulate in proc freq like this to achive the output...

proc freq data = test;

       tables job / out = test1(rename = (count = sum_sal) drop = percent) nocum nopercent;

       by deptno;

       weight sal;

run;

And ya by default, SAS will produce the Frequency as column name in Proc Freq output as it is one kind of Statistics that SAS is calculating so as per my knowledge, we cant change the output except you can eliminated the cumilative stat in proc freq but cant change the name of any stat in output...

Thanks,

Super Contributor
Posts: 266

Re: proc freq

Posted in reply to UrvishShah

thanks urvasi...

Regular Contributor
Posts: 195

Re: proc freq

@Aman4SAS, Welcome...By the way, My name is Urvish not Urvasi...

Super Contributor
Posts: 266

Re: proc freq

Posted in reply to UrvishShah

sincerely apology..... 

Regular Contributor
Posts: 195

Re: proc freq

No Problem, Happy to have discussion with you...

🔒 This topic is solved and locked.

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

Discussion stats
  • 9 replies
  • 415 views
  • 3 likes
  • 4 in conversation