LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 28 May 2010 13:59:01 -0500
Reply-To:     "Data _null_;" <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Data _null_;" <iebupdte@GMAIL.COM>
Subject:      Re: Redirect SAS Log (temporarily) to a Windows '/dev/null'
              equivalent?
Comments: To: "Choate, Paul@DDS" <Paul.Choate@dds.ca.gov>
In-Reply-To:  <AANLkTikbZCilBCQ07vDSNr-tKlTxXhoJO-suy9BNc9ZD@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

This is skipping the first record after the line of names add the trailing at to

input (_v[*])(:$upcase32.);

as

input (_v[*])(:$upcase32.) @;

On 5/28/10, Data _null_; <iebupdte@gmail.com> wrote: > Pauls nice solution helped me see the problem. Funny how that works. > I think there is one more bit to the problem in that a CSV can have > extra variables that may be mixed into the CSVs in any column. I've > modifed Paul's program to include that complication. > > If you know the variables and you know the attributes for the > variables you can declare them and with the help of the HASH , CALL > VNEXT, arrays and INFILE/INPUT you can read them. > > > /*set up some data*/ > proc export data=sashelp.class replace > outfile='class0.csv' > dbms=csv; > run; > data class1; > z = 1; > retain name sex height; > char = 'this is char'; > set sashelp.class(drop=weight); > x = 4; > run; > proc export replace > outfile='class1.csv' > dbms=csv; > run; > > /*read columns from a list of CSVs*/ > /*filename classes ('class0.csv','class1.csv','class0.csv') ;*/ > filename classes 'class*.csv'; > > data AllCSVs(drop=_:); > if 0 then set sashelp.class(/*drop=age*/); > array _n[*] _numeric_; > array _c[*] _character_; > > link main; > stop; > > Missing: > call missing(of _all_); > return; > > Main: > length _name_ $32 _type_ $1 _i_ 8; > declare hash h; > > h = _new_ hash(); > h.definekey('_name_'); > h.definedata('_name_','_type_','_i_'); > h.definedone(); > > do while(1); > call vnext(_name_,_type_); > if _name_ eq '_name_' then leave; > select(_type_); > when('C') do; > _ci + 1; > _i_ = _ci; > end; > when('N') do; > _ni + 1; > _i_ = _ni; > end; > otherwise; > end; > putlog 'NOTE: ' (_name_ _type_ _i_)(=); > _name_ = upcase(_name_); > _rc_ = h.add(); > end; > > length File Filename $128 _skipvar $1; > array _v(10 /*or more*/) $32; > infile classes EOV=EOV FILENAME=File dsd end=eof missover length=length; > do _n_ = 1 by 1 while(not eof); > input @; > select; > when(_n_ eq 1 or EOV) do; > input (_v[*])(:$upcase32.); > putlog 'NOTE: ' _infile_; > filename = scan(file,-1,'\'); > EOV = 0; > end; > when(length gt 0) do; > do _j_ = 1 to dim(_v) while(not missing(_v[_j_])); > _rc_ = h.find(key:_v[_j_]); > select(_rc_); > when(0) select(_type_); > when('C') input _c[_i_] @; > when('N') input _n[_i_] @; > otherwise; > end; > otherwise input _skipvar @; > end; > end; > output; > link missing; > end; > otherwise; > end; > input; > end; > return; > run; > proc print; > run; > > There is at least one more bit that should be added. If a CSV has > none of the target variables then you will get rows of all missing > values. That could be checked and that file skipped over so to speak. >


Back to: Top of message | Previous page | Main SAS-L page