SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

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 PVDG or any other it should extract the data from text file.

O/P:

A B C
10.00000 0.12668 0.01316
35.78947 0.03436 0.01361
61.57895 0.01944 0.01426
87.36842 0.01340 0.01506
113.15789 0.01017 0.01601
138.94737 0.00820 0.01711
164.73684 0.00689 0.01832
190.52632 0.00599 0.01962
216.31579 0.00533 0.02097
242.10526 0.00484 0.02234
270.00000 0.00444 0.02383
293.68421 0.00417 0.02507
319.47368 0.00393 0.02640
345.26316 0.00374 0.02770
371.05263 0.00358 0.02896
396.84211 0.00344 0.03019
422.63158 0.00332 0.03138
448.42105 0.00322 0.03254
474.21053 0.00313 0.03367
500.00000 0.00305 0.03476

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
%let key=  PVDG ;

data want;
infile 'c:\temp\test.txt' termstr=lf encoding='utf8' length=len;
input have $varying200. len;
retain found .;
if have =: "&key." then found=1;
if have ne: "&key." and anyalpha(have)=1 then found=0;
if found;
run;

View solution in original post

1 REPLY 1
Ksharp
Super User
%let key=  PVDG ;

data want;
infile 'c:\temp\test.txt' termstr=lf encoding='utf8' length=len;
input have $varying200. len;
retain found .;
if have =: "&key." then found=1;
if have ne: "&key." and anyalpha(have)=1 then found=0;
if found;
run;

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 879 views
  • 1 like
  • 2 in conversation