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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: