Link to home
Start Free TrialLog in
Avatar of labradorchik
labradorchikFlag for United States of America

asked on

How to open SAS dataset in Unix bash shell script and extract a certain variable from that dataset?

I am looking for an example of how to open .DAT in the Unix bash shell script and then extract a particular variable from that .DAT file into a different file.

Please note: this is how this function was done in VAX DCL code

open/read indat myfile.dat
 read_loop: 
  read/end_of_file=endit indat var1
  var2=f$extract(0,2,var1)
   if f$search("mydir1:file2.s''var2'") .nes. " " 
    then  
    del mydir1:file2.s'var2';* 
   endif
endit:
 close indat
 del myfile.dat;*

Open in new window


Any examples or comments on how this might be done in the Unix bash shell script will be greatly appreciated!!
Avatar of ahoffmann
ahoffmann
Flag of Germany image

> .. extract a particular variable ..
could you please give an example what you want to extract

maybe this helps:
  grep  " mydir1" myfile.dat
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of labradorchik

ASKER

noci, thank you very much for your help!!!
I probably will use your example #2. Looks very different from the VAX DCL code.
Avatar of noci
noci

example1 & 2 stay relatevely close to the DCL original...
example 3 is most unix like...
And you're right bash shell doesn't look like DCL.
Thank you for your comments!!