Hello, any input would be appreciated, I'm trying to do the problem with a do loop statement but I cannot produce the expected output.
amount with levels 0.9, 0.8, 0.7 and 0.6, and concentration with levels 1%, 1.5%, 2%, 2.5% and 3%, to chemical reaction time.
The data contains: 10.9 11.5 9.8 12.7 10.6 9.2 10.3 9.0 10.6 9.4 8.7 9.7 8.2 9.4 8.5 7.2 8.6 7.5 9.7 7.7
Each row corresponds to the levels of amount and each column corresponds to the levels of concetration.
Create a permanent SAS data set with this format: concentration amount time
1% 0.9 10.9
1.5% 0.9 11.5
. . .
2.5% 0.6 9.7
3% 0.6 7.7
Thanks.
Please post what you’ve tried so far. It’s easier to help point out where things need to be fixed.
Your question is also a bit unclear though so think you’re trying to create a SAS data set out of the values below the table? And a second table of all possible combinations, ergo the do loop?
@SuperSaiyan wrote:
Hello, any input would be appreciated, I'm trying to do the problem with a do loop statement but I cannot produce the expected output.
amount with levels 0.9, 0.8, 0.7 and 0.6, and concentration with levels 1%, 1.5%, 2%, 2.5% and 3%, to chemical reaction time.
The data contains: 10.9 11.5 9.8 12.7 10.6 9.2 10.3 9.0 10.6 9.4 8.7 9.7 8.2 9.4 8.5 7.2 8.6 7.5 9.7 7.7
Each row corresponds to the levels of amount and each column corresponds to the levels of concetration.
Create a permanent SAS data set with this format: concentration amount time
1% 0.9 10.9
1.5% 0.9 11.5
. . .
2.5% 0.6 9.7
3% 0.6 7.7
Thanks.
The question was also bit unclear to me, but I think my teacher wants to produce repeated values for the concentration levels and amount levels per reaction time. First I tried merging, but as expected it only merged the data.
data chemical;
do amount =0.9,0.8,0.7,0.6;
do concentration=1%,1.5%,2%,2.5%,3%;
input amount concentration time;
output;
end;
end;
datalines;
10.9 11.5 9.8 12.7 10.6 9.2 10.3 9.0 10.6 9.4 8.7 9.7 8.2 9.4 8.5 7.2 8.6 7.5 9.7 7.7
;
run;
tried using the codes above but it shows error
This is not valid:
1%,1.5%,2%,2.5%,3%;
Use a number then apply a format. Also use the {i} code window for code to retain formatting:
data chemical; do amount =0.9,0.8,0.7,0.6; do concentration=1 to 3 by 0.5; output; end; end; run;
As for why you have the datalines there at all is a mystery to me? Explain what you want out.
Hello,
I tried another one using
data chemical;
do amount = .9 , .8 , .7 , .6 ;
do concentration= "1%" , "1.5%" , "2%" , "2.5%" , "3%" ;
input time@@;
output;
end;
end;
datalines;
10.9 11.5 9.8 12.7 10.6
9.2 10.3 9.0 10.6 9.4
8.7 9.7 8.2 9.4 8.5
7.2 8.6 7.5 9.7 7.7
;
run;
proc print data=chemical;
run;
but it cannot read the percentage with decimal point as expected,
it show
Use the code window = {i}. Something like:
data times; input time@@; datalines; 10.9 11.5 9.8 12.7 10.6 9.2 10.3 9.0 10.6 9.4 8.7 9.7 8.2 9.4 8.5 7.2 8.6 7.5 9.7 7.7 ; run; data want; set times; do amount=0.9 to 0.6 by -0.1; do concentration=1 to 3 by 0.5; output; end; end; format concentration percent 4.1; run;
I tried running the codes you gave but the ouput is attache here,
Typo, there was a space after the word percent which shouldn't be there:
data times; input time@@; datalines; 10.9 11.5 9.8 12.7 10.6 9.2 10.3 9.0 10.6 9.4 8.7 9.7 8.2 9.4 8.5 7.2 8.6 7.5 9.7 7.7 ; run; data want; set times; do amount=0.9 to 0.6 by -0.1; do concentration=1 to 3 by 0.5; output; end; end; format concentration percent4.1; run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.