From: hallbird on 27 Dec 2009 16:26 Hi, this my very first post, I hope you can help in this I want Dynamic path reader, " Name=Customer; proc import out=Customer datafile='C:\Users\hallbird\Load\A\'||Name||'.csv' dbms=csv replace; getnames=YES; DATAROW=2; run; " But still i can't make it, is there's any solution for it
From: Arthur Tabachneck on 27 Dec 2009 17:55 Hallbird, If we were playing Jeopardy, I think the answer might be something like: what is a macro-wrapper! Does the following describe what you are trying to do? %macro doimport (Customer); proc import out=&Customer. datafile="C:\Users\hallbird\Load\A\&Customer..csv" dbms=csv replace; getnames=YES; DATAROW=2; run; %mend; %doimport(test) Where 'test' is the name of the company (i.e., the input file is test.csv and the output file is work.test). If that does what you want, ensure that you use double quote marks around the path of the datafile=. HTH, Art ------------- On Dec 27, 4:26 pm, hallbird <hallbi...(a)gmail.com> wrote: > Hi, > this my very first post, I hope you can help in this > I want Dynamic path reader, > > " > Name=Customer; > proc import > out=Customer datafile='C:\Users\hallbird\Load\A\'||Name||'.csv' > dbms=csv > replace; > getnames=YES; > DATAROW=2; > run; > " > But still i can't make it, is there's any solution for it
From: Mary on 27 Dec 2009 19:51 Hey, I was named a macro wrapperolic or something like that a year ago :-) I think the point must be; that we are "wrapping code" in a macro because we need to use something only the macro language has, and otherwise it would be in open code. The most common example is the %do loop: %macro wrapper; %do i=1 %to 3 /* stuff to do three times %end; %mend wrapper; I still do this a lot, and don't think it is bad code, and primarily am loading up a data set with the parameters and then pull for each loop. R has do and if statements in open code, but SAS does not, so that necessitates using a macro only for the use of %do or %if statements. -Mary --- art297(a)NETSCAPE.NET wrote: From: Arthur Tabachneck <art297(a)NETSCAPE.NET> To: SAS-L(a)LISTSERV.UGA.EDU Subject: Re: Dynamic path reader, Date: Sun, 27 Dec 2009 14:55:06 -0800 Hallbird, If we were playing Jeopardy, I think the answer might be something like: what is a macro-wrapper! Does the following describe what you are trying to do? %macro doimport (Customer); proc import out=&Customer. datafile="C:\Users\hallbird\Load\A\&Customer..csv" dbms=csv replace; getnames=YES; DATAROW=2; run; %mend; %doimport(test) Where 'test' is the name of the company (i.e., the input file is test.csv and the output file is work.test). If that does what you want, ensure that you use double quote marks around the path of the datafile=. HTH, Art ------------- On Dec 27, 4:26 pm, hallbird <hallbi...(a)gmail.com> wrote: > Hi, > this my very first post, I hope you can help in this > I want Dynamic path reader, > > " > Name=Customer; > proc import > out=Customer datafile='C:\Users\hallbird\Load\A\'||Name||'.csv' > dbms=csv > replace; > getnames=YES; > DATAROW=2; > run; > " > But still i can't make it, is there's any solution for it
From: Arthur Tabachneck on 27 Dec 2009 20:21 Mary, The term was 'macrowrapperholic', but I never intended to imply that the SAS macro language wasn't useful. To the contrary, I often find it the easiest, quickest, most repeatable and most useful way to accomplish some tasks. While some of our psychologist friends might take exception with me (although I, too, am one of them), one can consume alcohol, even on a daily basis, without becoming an alcoholic. The problem is identifying that line that distinguishes between 'normal' and 'holic'. As with all varieties of 'holics', its often a difficult line to see when one has crossed it and, most importantly, being able to identify when its effects are more debilitating than constructive. My sincere apologies if I offended you last year (or however long ago that was), as my intent was not to pick on you but, rather, to warn new users not to overuse the SAS macro language when simpler solutions are available. Art -------- On Sun, 27 Dec 2009 16:51:50 -0800, Mary <mlhoward(a)AVALON.NET> wrote: >Hey, I was named a macro wrapperolic or something like that a year ago :-) > >I think the point must be; that we are "wrapping code" in a macro because >we need to use something only the macro language has, and otherwise it would >be in open code. The most common example is the %do loop: > >%macro wrapper; > >%do i=1 %to 3 > /* stuff to do three times >%end; > >%mend wrapper; > >I still do this a lot, and don't think it is bad code, and primarily am loading >up a data set with the parameters and then pull for each loop. R has do and if >statements in open code, but SAS does not, so that necessitates using a macro >only for the use of %do or %if statements. > >-Mary > >--- art297(a)NETSCAPE.NET wrote: > >From: Arthur Tabachneck <art297(a)NETSCAPE.NET> >To: SAS-L(a)LISTSERV.UGA.EDU >Subject: Re: Dynamic path reader, >Date: Sun, 27 Dec 2009 14:55:06 -0800 > >Hallbird, > >If we were playing Jeopardy, I think the answer might be something >like: what is a macro-wrapper! > >Does the following describe what you are trying to do? > >%macro doimport (Customer); > proc import > out=&Customer. > datafile="C:\Users\hallbird\Load\A\&Customer..csv" > dbms=csv > replace; > getnames=YES; > DATAROW=2; > run; >%mend; > >%doimport(test) > >Where 'test' is the name of the company (i.e., the input file is >test.csv and the output file is work.test). If that does what you >want, ensure that you use double quote marks around the path of the >datafile=. > >HTH, >Art >------------- >On Dec 27, 4:26 pm, hallbird <hallbi...(a)gmail.com> wrote: >> Hi, >> this my very first post, I hope you can help in this >> I want Dynamic path reader, >> >> " >> Name=Customer; >> proc import >> out=Customer datafile='C:\Users\hallbird\Load\A\'||Name||'.csv' >> dbms=csv >> replace; >> getnames=YES; >> DATAROW=2; >> run; >> " >> But still i can't make it, is there's any solution for it
From: hallbird on 28 Dec 2009 14:33 Thanks all for interactive, to honest I didn't expect in such way, might I thought my post will goes for days to be answered, but my thought was wrong for luck thanks Arthur Tabachneck, I've test the code it's working in such way I want, and also mary for sharing.
|
Next
|
Last
Pages: 1 2 3 Prev: convert an array into a string Next: Discriminant Analysis in SAS XXXX |