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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

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

9 REPLIES 9
PaigeMiller
Diamond | Level 26

Can we change the level of column frequency

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

--
Paige Miller
Aman4SAS
Obsidian | Level 7

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

Jagadishkatam
Amethyst | Level 16

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
Aman4SAS
Obsidian | Level 7

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

UrvishShah
Fluorite | Level 6

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,

Aman4SAS
Obsidian | Level 7

thanks urvasi...

UrvishShah
Fluorite | Level 6

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

Aman4SAS
Obsidian | Level 7

sincerely apology..... 

UrvishShah
Fluorite | Level 6

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 9 replies
  • 5992 views
  • 3 likes
  • 4 in conversation