BookmarkSubscribeRSS Feed
mcbain
Calcite | Level 5

Hi,

I have a data set that i will like to reduce the number of rows by summing the values of the each column for certain values of the variable SpdCat (1,2,3,4 and 5), and put it in one row (that i will index 1) of the same dimension. So, each time i see rows that has 1,2,3,4, and 5 as index in the SpdCat column, i want to sum the value of those columns. Here is a screen shot of the dataCapture. Data.PNG

Can some one help here?

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi:

  It's not quite clear to me what you want to summarize -- you want to summarize the values of SPDCAT or you want to summarize the values of Data1-Data13??

 

  What code have you tried? Have you tried PROC MEANS or PROC TABULATE? You can of course, do custom summarizing in a DATA step program have you tried that?

 

  I can't visualize what your output would look like. Essentially, you are asking people to duplicate the data in your screen shot in order to help you. Can you post your data as a datalines program so that anyone can create the data and what would also be useful would be seeing an example of what the desired output would look like.

 

Cynthia

novinosrin
Tourmaline | Level 20

Thank you mam @Cynthia_sas  as I second to your thoughts. 

 

Hi @mcbain  I am not sure if i understand your requirement nor I am able to create a sample of what you HAVE and what you WANT, which is generally expected from original posters. You could paste as plain text that is neat for us to copy paste easily.

 

Anyways, I am gonna take a guess though. 

 


data want;
 set have end=z;
 array t(*) data1-data13;
 if spdcat in (1:5) then sum+t(spdcat);
 if z;
 keep sum;
run;
Kurt_Bremser
Super User

Define what you mean by "dimension" and supply your example data in a usable form as a data step with datalines, along with an example of your expected output (dataset or report?).

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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