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 2003, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 30 May 2003 12:39:07 -0400
Reply-To:     Ira Roberts <ir10@MAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ira Roberts <ir10@MAIL.COM>
Subject:      Re: Transferring data set from VAX to PC

.CSV always works, but in my personal experience it would be better to output .CSV file rather than creating it in SAS Viewer. The latter tends to make mistakes when outputting the dataset that has many variables with missing values.

PROC EXPORT is the simplest solution, but if it didn't work for whatever reason, then you may want to use the AUTOCSV macro:

*** DROPVARS is what you do not want to see in a .CSV file. * *** DLM is the delimiter of choice *;

%macro autocsv(dsname,flname,dropvars=%str( ),dlm=%str(,));

proc contents noprint data=&dsname(drop=&dropvars.) out=varname(keep=name npos); proc sort; by npos; run;

data _null_; do i=1 to nobs; set varname nobs=nobs end=end; call symput('num'||trim(left(put(i,4.))),trim(name)); if end then call symput('nvars',trim(left(put(nobs,8.)))); end; run;

data _null_; set &dsname; file "&flname..csv" delimiter="&dlm." lrecl=32767 ; if _n_=1 then do; %do i=1 %to %eval(&nvars.); %if &i.=1 %then %do; put "&&num&i" %end; %else %do; "&dlm.&&num&i" %end; %end; ; end;

%do i=1 %to %eval(&nvars.); %if &i.=1 %then %do; put &&num&i %end; %else %do; &&num&i %end; %end; ; run; %mend;

data smth ; infile cards ; a + 1 ; input blah1 blah2 blah3 $16.; blah4 = substr(blah3,1,1) ; output ; cards ; 1 5 AAA 2 6 BBB__CCC ; run; proc contents;run; proc print;run;

options mprint nocenter;

%autocsv(smth,test01,dlm=|,dropvars=blah1 blah2); %autocsv(smth,test02,dropvars=blah2 blah3,dlm=$); %autocsv(smth,test03,dropvars=blah3 blah4); *<** comma is the default;

HTH, IRa


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