BookmarkSubscribeRSS Feed
Keets
Calcite | Level 5

Hello,

 

I have a big dataset with 3 values that are of interest. ID, Visite and WSL_Flaechen.

Visite ranges from 1 to 5 and WSL_Flaechen from 1 to 2.

With the following code i managed to group by Visite and count the WSL_Flaechen for each ID.

asdf2.png

asdf.png

But instead i want count of WSL_Flaechen (blue arrow) to be multiplied with the value of WSL_Flaechen (red arrow) and display the sum of that for each ID.

So ID 4001 has

(1*8 + 2*12) = 32 on Visite 1 and

2 + 20 = 22 on Visite 2

and 26 on Visite 3

and so on...

The dataset only has 1s and 2s and the WSL_Flaechen field and i cant seem to just sum them up. I only display the count of 1s and 2s in seperate fields. How to i properly use the sum function here?

When i try to get sum in there i get the "statistical variable other than N without analysis variable" error.

 

Sincerely,

Keets

1 REPLY 1
Reeza
Super User

Look at the WEIGHT or FREQ statement within the PROC instead - and double check your numbers, especially if you have any missing values or non integers. 

 


@Keets wrote:

Hello,

 

I have a big dataset with 3 values that are of interest. ID, Visite and WSL_Flaechen.

Visite ranges from 1 to 5 and WSL_Flaechen from 1 to 2.

With the following code i managed to group by Visite and count the WSL_Flaechen for each ID.

asdf2.png

asdf.png

But instead i want count of WSL_Flaechen (blue arrow) to be multiplied with the value of WSL_Flaechen (red arrow) and display the sum of that for each ID.

So ID 4001 has

(1*8 + 2*12) = 32 on Visite 1 and

2 + 20 = 22 on Visite 2

and 26 on Visite 3

and so on...

The dataset only has 1s and 2s and the WSL_Flaechen field and i cant seem to just sum them up. I only display the count of 1s and 2s in seperate fields. How to i properly use the sum function here?

When i try to get sum in there i get the "statistical variable other than N without analysis variable" error.

 

Sincerely,

Keets


 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 847 views
  • 0 likes
  • 2 in conversation