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

Dear all,

 

I would like to make a statistic like a highlight part of the following, 

TIM图片20180912122252.png

I have the dataset like this 

TIM图片20180912122316.png

 

the psn_name is the company's name. the No_of_cit20051 is the month Jan 2005, the number in the table (like 0 and 4) is the number of patent applications made at that month. I have the number of patent applications made by each company each month during the period between 2005 and 2010.

 

I am confused about how to make the second table like the first one? Could you please give me some suggestion?

 

thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@France wrote:

Dear all,

 

I would like to make a statistic like a highlight part of the following, 

TIM图片20180912122252.png

I have the dataset like this 

TIM图片20180912122316.png

 

the psn_name is the company's name. the No_of_cit20051 is the month Jan 2005, the number in the table (like 0 and 4) is the number of patent applications made at that month. I have the number of patent applications made by each company each month during the period between 2005 and 2010.

 

I am confused about how to make the second table like the first one? Could you please give me some suggestion?

 

thanks in advance.


The first one is a report. Possibly made by Proc Tabulate or Proc Report or summarizing the data with proc means or summary and then using proc print.

 

You should have access to the data set SASHELP.STOCKS. Run this code to see an example of one code approach that makes a similar report:

proc tabulate data=sashelp.stocks style=journal;
   class stock;
   var open;
   table stock='',
        open*( n mean p25='25th percentile' median p75='75th percentile' p95='95th percentile' std='SD' max min)
         /box='Stock';
run;

If that looks like what you want then look closely at the data set SASHELP.STOCKS. Notice that there is one record for each stock and date with the value of OPEN (or close or hig or low or volume).

 

Proc transpose is one way to take a data set that has multiple variables such as your monthly values and create the data in a one row per month.

Your data is further complicated by actually having a DATE as part of the variable name.

Here is a small example of something similar. Replace the var20151 etc with your variable names. You can use a variable list such as

 

VAR No_of_cit: ;

to use all of the variables that start with that name.

 

Then use a proc tabulate similar to what I did above.

To filter to a specific date you would a WHERE statement in the proc transpose that looks something like

   WHERE   '01JAN2005'd le date lt '01JAN2011'd;

 

OR you could use Proc Means/Summary with a similar Where statement

Proc summary data=want nway;
   class company;
   var Patents;
   output out=want (drop= _:) 
         n= mean= p25=  median= p75= p95= std= max= min= /autoname;
run;

Which creates a data set with one row per company and statistics named Patents_n Patents_mean etc. with the statistic as a suffix to the summarized variable.

 

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Transpose each psn_name, then use proc tabulate to calculate the statistics and format the table.

PG
ballardw
Super User

@France wrote:

Dear all,

 

I would like to make a statistic like a highlight part of the following, 

TIM图片20180912122252.png

I have the dataset like this 

TIM图片20180912122316.png

 

the psn_name is the company's name. the No_of_cit20051 is the month Jan 2005, the number in the table (like 0 and 4) is the number of patent applications made at that month. I have the number of patent applications made by each company each month during the period between 2005 and 2010.

 

I am confused about how to make the second table like the first one? Could you please give me some suggestion?

 

thanks in advance.


The first one is a report. Possibly made by Proc Tabulate or Proc Report or summarizing the data with proc means or summary and then using proc print.

 

You should have access to the data set SASHELP.STOCKS. Run this code to see an example of one code approach that makes a similar report:

proc tabulate data=sashelp.stocks style=journal;
   class stock;
   var open;
   table stock='',
        open*( n mean p25='25th percentile' median p75='75th percentile' p95='95th percentile' std='SD' max min)
         /box='Stock';
run;

If that looks like what you want then look closely at the data set SASHELP.STOCKS. Notice that there is one record for each stock and date with the value of OPEN (or close or hig or low or volume).

 

Proc transpose is one way to take a data set that has multiple variables such as your monthly values and create the data in a one row per month.

Your data is further complicated by actually having a DATE as part of the variable name.

Here is a small example of something similar. Replace the var20151 etc with your variable names. You can use a variable list such as

 

VAR No_of_cit: ;

to use all of the variables that start with that name.

 

Then use a proc tabulate similar to what I did above.

To filter to a specific date you would a WHERE statement in the proc transpose that looks something like

   WHERE   '01JAN2005'd le date lt '01JAN2011'd;

 

OR you could use Proc Means/Summary with a similar Where statement

Proc summary data=want nway;
   class company;
   var Patents;
   output out=want (drop= _:) 
         n= mean= p25=  median= p75= p95= std= max= min= /autoname;
run;

Which creates a data set with one row per company and statistics named Patents_n Patents_mean etc. with the statistic as a suffix to the summarized variable.

 

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 626 views
  • 0 likes
  • 3 in conversation