Dear friends,
I need to perform linear interpolations
I do it correctly when I have only one dataset in one table
However, I have many many different datasets in one table and each dataset should have its own interpolation curve
Let's look at a simple example with only two datasets (A & B):
| NAME | DEPTH | X | Y |
| A | 0,00 | 496323,56 | 6277756,14 |
| 0,50 | , | , | |
| 1,00 | , | , | |
| 1,50 | , | , | |
| 2,00 | , | , | |
| 2,50 | , | , | |
| 3,00 | , | , | |
| 3,50 | , | , | |
| 4,00 | , | , | |
| 4,50 | , | , | |
| 5,00 | , | , | |
| 5,50 | , | , | |
| 6,00 | , | , | |
| A | 6,50 | 496210,94 | 6277828,15 |
| 7,00 | , | , | |
| 7,50 | , | , | |
| 8,00 | , | , | |
| 8,50 | , | , | |
| 9,00 | , | , | |
| 9,50 | , | , | |
| 10,00 | , | , | |
| 10,50 | , | , | |
| A | 11,00 | 496210,87 | 6277828,25 |
| B | 0,00 | 516239.55347 | 6247816.3269 |
| 0.5 | |||
| 1,00 | |||
| 1,50 | |||
| 2,00 | |||
| 2,50 | |||
| 3,00 | |||
| 3,50 | |||
| 4,00 | |||
| 4,50 | |||
| 5,00 | |||
| 5,50 | |||
| B | 6,00 | 516239.55347 | 6247816.3269 |
| 6,50 | |||
| 7,00 | |||
| 7,50 | |||
| 8,00 | |||
| 8,50 | |||
| B | 9,00 | 516239.51534 | 6247816.3202 |
| 9,50 | |||
| 10,00 | |||
| 10,50 | |||
| 11,00 | |||
| 11,50 | |||
| 12,00 | |||
| B | 12,50 | 516239.47966 | 6247816.3124 |
I use the following proc procedure to perform linear regression for one dataset:
proc expand data=&_INPUT1 out=&_OUTPUT1;
convert X=linear_X / method=join;
id DEPTH;
run;
proc expand data=&_INPUT1 out=&_OUTPUT1;
convert Y=linear_Y / method=join;
id DEPTH;
run;
The interpolation will fill the missing values for X and Y
However, when I have two datasets (in this case A & B) or more I can't use this formula
I know I need some kind of DO LOOP somewhere but I don't know where and how I should use it
Can you please help me with it?
Thank you vey much!
Best regards
Farshid
Does this help you?
data have;
input NAME $ (DEPTH X Y)(:comma18.4);
infile datalines dsd dlm='|';
datalines;
A|0,00 |496323,56 |6277756,14
|0,50 | |
|1,00 | |
|1,50 | |
|2,00 | |
|2,50 | |
|3,00 | |
|3,50 | |
|4,00 | |
|4,50 | |
|5,00 | |
|5,50 | |
|6,00 | |
A|6,50 |496210,94 |6277828,15
|7,00 | |
|7,50 | |
|8,00 | |
|8,50 | |
|9,00 | |
|9,50 | |
|10,00| |
|10,50| |
A|11,00|496210,87 |6277828,25
B|0,00 |516239.55347|6247816.3269
|0.5 | |
|1,00 | |
|1,50 | |
|2,00 | |
|2,50 | |
|3,00 | |
|3,50 | |
|4,00 | |
|4,50 | |
|5,00 | |
|5,50 | |
B|6,00 |516239.55347|6247816.3269
|6,50 | |
|7,00 | |
|7,50 | |
|8,00 | |
|8,50 | |
B|9,00 |516239.51534|6247816.3202
|9,50 | |
|10,00| |
|10,50| |
|11,00| |
|11,50| |
|12,00| |
B|12,50|516239.47966|6247816.3124
;
data temp(drop=_:);
set have;
if not missing(Name) then _Name=Name;
Name=coalescec(Name, _Name);
retain _Name;
run;
proc sort data=temp;
by Name DEPTH;
run;
proc expand data=temp out=want;
by Name;
id DEPTH;
convert X=linear_X / method=join;
convert Y=linear_Y / method=join;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.