New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
N8
Obsidian | Level 7 N8
Obsidian | Level 7

Hi everyone,

 

My question: I have a dataset with three columns [ID $; Group (class variable); Value (continuous)] - sample code provided below.

 

My goal: change values for group 0 to be equivalent to the values for group 1 (by equivalent I want both groups to have same average).

 

The problem: I can't make up values. A member (ID) from Group 0 *must* take a value from group 1 (doesn't matter who) and the program needs to terminate once the averages between the two groups are equivalent (or ideally a user specified tolerance, say 1% or 5% within each other). The other problem is that the dataset has dozens of other records that I need to retain, so do not want to transpose. Exporting the Group=1 into a new dataset and then re-joining to the original is fine, but I would like the structure to remain in tact. 

 

Appreciate the help if someone has some time. Happy to clarify. Kind regards, Nate

 

data Step1;
input ID $ Continuous Group ;
datalines;
1 1792 0
6 1425 0
9 1782 0
10 2019 0
18 2294 0
20 1616 0
21 1551 0
24 1791 0
25 1828 0
26 1602 0
34 1611 0
35 1424 0
2 2498 1
3 2318 1
4 1848 1
5 1698 1
7 1964 1
8 2066 1
11 2348 1
12 2127 1
13 2340 1
14 2423 1
15 2184 1
16 2337 1
17 2233 1
19 1817 1
22 2196 1
23 2697 1
27 2156 1
28 2488 1
29 1977 1
30 2074 1
31 2084 1
32 2112 1
33 2251 1
36 1509 1
37 2357 1
38 2501 1
39 1309 1

;
run;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Do you have SAS/QC ?

 

data Step1;
input ID $ number ;
datalines;
1 1792 0
6 1425 0
9 1782 0
10 2019 0
18 2294 0
20 1616 0
21 1551 0
24 1791 0
25 1828 0
26 1602 0
34 1611 0
35 1424 0
2 2498 1
3 2318 1
4 1848 1
5 1698 1
7 1964 1
8 2066 1
11 2348 1
12 2127 1
13 2340 1
14 2423 1
15 2184 1
16 2337 1
17 2233 1
19 1817 1
22 2196 1
23 2697 1
27 2156 1
28 2488 1
29 1977 1
30 2074 1
31 2084 1
32 2112 1
33 2251 1
36 1509 1
37 2357 1
38 2501 1
39 1309 1
;
run;

data treatments;
 trt=1;output;
 trt=2;output;
run;

proc optex data=treatments seed=123 coding=orthcan;
class trt;
model trt;

blocks design=step1;
model number;
output out=want;
run;

proc means data=want n mean std nway;
class trt;
var number;
run;

View solution in original post

4 REPLIES 4
Ksharp
Super User

Do you have SAS/QC ?

 

data Step1;
input ID $ number ;
datalines;
1 1792 0
6 1425 0
9 1782 0
10 2019 0
18 2294 0
20 1616 0
21 1551 0
24 1791 0
25 1828 0
26 1602 0
34 1611 0
35 1424 0
2 2498 1
3 2318 1
4 1848 1
5 1698 1
7 1964 1
8 2066 1
11 2348 1
12 2127 1
13 2340 1
14 2423 1
15 2184 1
16 2337 1
17 2233 1
19 1817 1
22 2196 1
23 2697 1
27 2156 1
28 2488 1
29 1977 1
30 2074 1
31 2084 1
32 2112 1
33 2251 1
36 1509 1
37 2357 1
38 2501 1
39 1309 1
;
run;

data treatments;
 trt=1;output;
 trt=2;output;
run;

proc optex data=treatments seed=123 coding=orthcan;
class trt;
model trt;

blocks design=step1;
model number;
output out=want;
run;

proc means data=want n mean std nway;
class trt;
var number;
run;
N8
Obsidian | Level 7 N8
Obsidian | Level 7

Hi Ksharp - and thank you. Sadly, no, running SAS University Edition via virtual machine. 

N8
Obsidian | Level 7 N8
Obsidian | Level 7

Thanks Ksharp - this solution does work.

SAS Innovate 2025: 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. Sign up by March 14 for just $795.


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
  • 681 views
  • 2 likes
  • 2 in conversation