sas - CSV document import by using filename statement -



sas - CSV document import by using filename statement -

i want read csv document using filename statement in sas excel included variable names first line when input variable names using input statement--there going mistake. how can deal situation?

filename outdata "c:\users\xiang\desktop\crime2005.csv"; info crime; infile outdata dlm="," dsd ; proc means mean std maxdec=1 ; proc print; run;

first off - you're confusing things bit saying 'via filename statement'. via datastep. filename statement happens relatively little component of this.

second, let's proper sas indenting can see what's going on:

filename outdata "c:\users\xiang\desktop\crime2005.csv"; info crime; infile outdata dlm="," dsd ; input [your-variable-list]; run; proc means data=crime mean std maxdec=1 ; run; proc print data=crime; run;

data steps , procs end run (except procs end in quit). each of these separate step, include run. include data= , unless you're using fancy programming trick. 'data' in first column, not indented - info step master statement, not filename.

these create code readable, , protect mistakes. readable code important, if work alone; means understand wrote 5 years ago, 5 years now.

your original question - how avoid errors header row?

filename outdata "c:\users\xiang\desktop\crime2005.csv"; info crime; infile outdata dlm="," dsd firstobs=2; input [your-variable-list]; run;

there go. firstobs=2 tells sas skip first line [ie, header row].

one thing might seek proc import. proc import dbms=csv handy - set in log finish info step of code read file in yourself. while don't recommend proc import production code [as makes poor decisions character/numeric formatting , lengths, among other things], helpful see how started input statement.

proc import file=outdata out=crime dbms=csv replace; run;

then @ log, , re-create code out (removing line numbers); can modify heart's content.

sas

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -