BookmarkSubscribeRSS Feed
luinkhandakar
Calcite | Level 5

What will be the SAS code for the following information? 

There are 4 tea brands, known as Q, W, E, and R and I have 100 tasters for each brand and want to rate them on a 0 to 100 scale of tea perfection. I produce tea brand W, my interest is to compare it with the other 3 brands.

4 REPLIES 4
Kurt_Bremser
Super User

SAS code is highly dependent on the data, so you need to supply example data in usable form, against which we can write and test code.

Usable form means a data step with datalines, posted into a code box ("little running man" button).

By also posting the expected result you want to get out of that data, you provide the essential requisites for code development.

PaigeMiller
Diamond | Level 26

A meaningful Subject line that describes the problem, rather than the generic subject that could apply to virtually any question asked here, is preferred, and makes everything here at the SAS Communities run better. Please go back to your original post and change the Subject line to one that describes the problem you are trying to solve.

--
Paige Miller
Ksharp
Super User
PROC PRINQUAL
PGStats
Opal | Level 21

This, for a start?

 

data have;
input tasterId    Q   W   E   R;
datalines;
1   85  100 51  76
2   75  91  65  64
3   79  91  69  73
4   85  88  61  77
5   83  94  58  73
6   88  97  52  61
7   76  82  53  68
8   89  86  57  64
9   86  90  63  78
10  81  100 67  62
11  75  100 51  74
12  86  86  66  80
13  73  94  51  80
14  79  80  68  65
15  70  87  56  69
16  87  80  66  72
17  80  92  69  61
18  84  92  59  65
19  75  94  54  68
20  90  98  67  72
;

proc transpose data=have out=ratings(rename=col1=rating) name=tea ;
by tasterId;
var Q--R;
run;

proc sql;
select
    tea label="Tea",
    sum(prefered) as nbPrefered,
    count(tasterId) as nbTasters
from 
    (select
        tea,
        tasterId,
        rating >= max(rating) as prefered
    from
        ratings
    group by tasterId)
group by tea;
quit;
Tea 	nbPrefered 	nbTasters
E 	0 	20
Q 	3 	20
R 	0 	20
W 	18 	20
PG

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 853 views
  • 0 likes
  • 5 in conversation