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

I am a newbie with SAS. I need help in understanding the code below. Thank you!

 

 

PROC SUMMARY DATA=testdat.Input

CLASS CUSIP Date;

VAR PRCE;

OUTPUT OUT=testdat.range_all range=range_all n=countall ;

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

The code is missing a semi colon on the first line and missing a RUN; at the end. See the comments in the code below that helps to explain what it's doing. If you have further questions please post back. 

 

PROC SUMMARY DATA=testdat.Input; *specify to run a summary procedure on the data set INPUT;

CLASS CUSIP Date; *Group the summaries by CUSIP and DATE;

VAR PRCE; *Summarize the variable PRCE;

OUTPUT OUT=testdat.range_all range=range_all n=countall ; *output the results to a dataset called range_all, the statistics being calculated are the RANGE and N(count). The RANGE is stored in a variable called range_all and the count is stored in countall;

Run;

@Vinz867 wrote:

I am a newbie with SAS. I need help in understanding the code below. Thank you!

 

 

PROC SUMMARY DATA=testdat.Input

CLASS CUSIP Date;

VAR PRCE;

OUTPUT OUT=testdat.range_all range=range_all n=countall ;

 

 

 

 


 

View solution in original post

4 REPLIES 4
Reeza
Super User

The code is missing a semi colon on the first line and missing a RUN; at the end. See the comments in the code below that helps to explain what it's doing. If you have further questions please post back. 

 

PROC SUMMARY DATA=testdat.Input; *specify to run a summary procedure on the data set INPUT;

CLASS CUSIP Date; *Group the summaries by CUSIP and DATE;

VAR PRCE; *Summarize the variable PRCE;

OUTPUT OUT=testdat.range_all range=range_all n=countall ; *output the results to a dataset called range_all, the statistics being calculated are the RANGE and N(count). The RANGE is stored in a variable called range_all and the count is stored in countall;

Run;

@Vinz867 wrote:

I am a newbie with SAS. I need help in understanding the code below. Thank you!

 

 

PROC SUMMARY DATA=testdat.Input

CLASS CUSIP Date;

VAR PRCE;

OUTPUT OUT=testdat.range_all range=range_all n=countall ;

 

 

 

 


 

Vinz867
Fluorite | Level 6

When you say summarize the variance PRCE, is it summing up the prices based on the CUSIP and date?


@Reeza wrote:

The code is missing a semi colon on the first line and missing a RUN; at the end. See the comments in the code below that helps to explain what it's doing. If you have further questions please post back. 

 

PROC SUMMARY DATA=testdat.Input; *specify to run a summary procedure on the data set INPUT;

CLASS CUSIP Date; *Group the summaries by CUSIP and DATE;

VAR PRCE; *Summarize the variable PRCE;

OUTPUT OUT=testdat.range_all range=range_all n=countall ; *output the results to a dataset called range_all, the statistics being calculated are the RANGE and N(count). The RANGE is stored in a variable called range_all and the count is stored in countall;

Run;

@Vinz867 wrote:

I am a newbie with SAS. I need help in understanding the code below. Thank you!

 

 

PROC SUMMARY DATA=testdat.Input

CLASS CUSIP Date;

VAR PRCE;

OUTPUT OUT=testdat.range_all range=range_all n=countall ;

 

 

 

 


 


 

Reeza
Super User

@Vinz867 wrote:

When you say summarize the variance PRCE, is it summing up the prices based on the CUSIP and date?



Yes, it calculates the N and Range of the variable PRCE, for each unique combination of CUSIP and DATE.

Tom
Super User Tom
Super User

Since you did not include the NWAY option on your PROC SUMMARY statement this code will produce multiple sets of outputs in the same output dataset.  You can distinguish them by looking at the automatic variable _TYPE_ that it creates.

.

In your example you have two CLASS variables so _TYPE_ will have four possible values that result from two binary flags.

_TYPE_=00 will have one observation with the summary for all of the input data.

_TYPE_=3 ( or '11'b ) will have one observation for each distinct combination of the two class variables.

_TYPE_=2 and 1 ('10'b and '01'b) will have the summary for each distinct value of just one of the two class variables considered independently.

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!

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