Dear All,
I need to extract a sub set of data from the text file. Here i have attached the input text file .
I have given the output below. when ever i pass the parameter SGT or any other it should extract the data from text file.
output:
*SGT
0.005 0.0 0.
0.040 0.005 0.
0.080 0.013 0.
0.120 0.026 0.
0.160 0.040 0.
0.200 0.058 0.
0.240 0.078 0.
0.280 0.100 0.
0.320 0.126 0.
0.360 0.156 0.
0.400 0.187 0.
0.440 0.222 0.
0.480 0.260 0.
0.520 0.300 0.
0.560 0.348 0.
0.600 0.400 0.
0.640 0.450 0.
0.680 0.505 0.
0.720 0.562 0.
0.760 0.620 0.
0.800 0.680 0.
0.840 0.740 0.
Do you mean something like this?:
data want;
infile cards4 missover;
input;
if _INFILE_ =: '*SGT' then
do until(a=.);
input;
a = input(scan(_INFILE_,1," "), ?? best32.);
b = input(scan(_INFILE_,2," "), ?? best32.);
if a>. then output;
end;
cards4;
**---------------------------- ROCK FLUID -------------------------------
*ROCKFLUID
*RPT
*SGT
0.005 0.0 0.
0.040 0.005 0.
0.080 0.013 0.
0.120 0.026 0.
0.160 0.040 0.
0.200 0.058 0.
0.240 0.078 0.
0.280 0.100 0.
0.320 0.126 0.
0.360 0.156 0.
0.400 0.187 0.
0.440 0.222 0.
0.480 0.260 0.
0.520 0.300 0.
0.560 0.348 0.
0.600 0.400 0.
0.640 0.450 0.
0.680 0.505 0.
0.720 0.562 0.
0.760 0.620 0.
0.800 0.680 0.
0.840 0.740 0.
*SWT
0.160 0.0 0.
0.200 0.002 0.
0.240 0.010 0.
0.280 0.020 0.
0.320 0.033 0.
0.360 0.049 0.
0.400 0.066 0.
0.440 0.090 0.
0.480 0.119 0.
0.520 0.150 0.
0.560 0.186 0.
0.600 0.227 0.
0.640 0.277 0.
0.680 0.330 0.
0.720 0.390 0.
0.760 0.462 0.
0.800 0.540 0.
0.840 0.620 0.
0.880 0.710 0.
0.920 0.800 0.
0.960 0.900 0.
0.995 1.0 0.
**-------------------------------- INITIAL CONDITION --------
*INITIAL
*VERTICAL *DEPTH_AVE *WATER_GAS
*REFPRES 3550.0
;;;;
run;
Bart
Do you mean something like this?:
data want;
infile cards4 missover;
input;
if _INFILE_ =: '*SGT' then
do until(a=.);
input;
a = input(scan(_INFILE_,1," "), ?? best32.);
b = input(scan(_INFILE_,2," "), ?? best32.);
if a>. then output;
end;
cards4;
**---------------------------- ROCK FLUID -------------------------------
*ROCKFLUID
*RPT
*SGT
0.005 0.0 0.
0.040 0.005 0.
0.080 0.013 0.
0.120 0.026 0.
0.160 0.040 0.
0.200 0.058 0.
0.240 0.078 0.
0.280 0.100 0.
0.320 0.126 0.
0.360 0.156 0.
0.400 0.187 0.
0.440 0.222 0.
0.480 0.260 0.
0.520 0.300 0.
0.560 0.348 0.
0.600 0.400 0.
0.640 0.450 0.
0.680 0.505 0.
0.720 0.562 0.
0.760 0.620 0.
0.800 0.680 0.
0.840 0.740 0.
*SWT
0.160 0.0 0.
0.200 0.002 0.
0.240 0.010 0.
0.280 0.020 0.
0.320 0.033 0.
0.360 0.049 0.
0.400 0.066 0.
0.440 0.090 0.
0.480 0.119 0.
0.520 0.150 0.
0.560 0.186 0.
0.600 0.227 0.
0.640 0.277 0.
0.680 0.330 0.
0.720 0.390 0.
0.760 0.462 0.
0.800 0.540 0.
0.840 0.620 0.
0.880 0.710 0.
0.920 0.800 0.
0.960 0.900 0.
0.995 1.0 0.
**-------------------------------- INITIAL CONDITION --------
*INITIAL
*VERTICAL *DEPTH_AVE *WATER_GAS
*REFPRES 3550.0
;;;;
run;
Bart
%let key= *SGT ;
data want;
infile 'c:\temp\k1r1.txt' termstr=lf length=len;
input want $varying400. len;
retain found .;
if want =: "&key." then found=1;
if first(want)='*' and want ne: "&key." then found=0;
if found;
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.