UCLA Academic Technology Services HomeServicesClassesContactJobs
Help the Stat Consulting Group by giving a gift             
Loading

SAS Code Fragments
Reading an electronic codebook and writing an input statement

data test;
  infile "e:\data\attach\dd6429cm.wave1" length=len;
  length junk $ 1 
         varname $ 8 x $ 80;
  input x $varying. len  @;
  if substr(x,1,1) = "D" then do;
    input @1 junk varname varlen varpos1 ;
	varpos2 = varpos1 + varlen - 1;
	output;
  end;
  else
  do;
    input ;
  end;
run;

proc print data=test;
  var varname varpos1 varpos2 ;
run;

data _null_;
  file "d:\temp\sasprog.txt" ;
  set test end=lastobs;
  if _n_ = 1 then put "input " ;
  put " " varname " " varpos1 "-" varpos2 ;
  if lastobs then put ";" ;
run;
 

How to cite this page

Report an error on this page or leave a comment

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California