Date: Wed, 9 Feb 2011 15:42:50 -0500
Reply-To: michael@bassettconsulting.com
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Michael Davis <michael@BASSETTCONSULTING.COM>
Subject: Re: Exporting into CSV woes...help!
In-Reply-To: <AANLkTi=7GryNU=v+WVteo1UUbnXyeNcpHC7jbC97Ze3p@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hello Rieza and Sterling and other SAS-L Friends,
I routinely
load CSV files into SAS in excess of 256 columns. You can, too.
I tend to stay from PROC EXPORT (or IMPORT) because I need to
control the variable type and column. I use LENGTH statements to
control the PDV (Program Data Vector) -- the assignment of character,
numeric (and numeric date/time), length, and order of variables. It
is more work than PROC IMPORT but it worth it in the end.
HTH.
Michael
On Wed, February 9, 2011 3:05 pm,
"Sterling Paramore" <gnilrets@GMAIL.COM> wrote:
>
Hi Rieza,
>
> CSV has been around for a long time and was
definitely not originally made
> for Excel. However, if you try
to open a CSV file with more than 256
> columns in an older
version of Excel, you may only see the first 256
> columns
> because of Excel's limitations, not the limitations of the CSV
format.
>
> Can you open up the file in Notepad and see
if all the columns you are
> expecting are there? If the file is
very large (GBs), you could try
> exporting only the first hundred
lines and opening that in Notepad to see
> what's there.
>
> -Sterling
>
> On Wed, Feb 9, 2011 at 11:49 AM,
Rieza Soelaeman
> <rsoelaeman@gmail.com>wrote:
>
>> Dear SAS-Lers,
>> I have a simple question for you.
Is it possible to export a dataset
>> with
>> 976
variables (columns) in its entirety into CSV format? I tried to use
>> Proc Export several times, and it would only export the first
256
>> variables...scouring the forums, it appears the reason
is b/c CSV was
>> originally made for Excel, where the max # of
columns is 256.
>>
>> If not, I was thinking about
breaking up the master dataset into 4
>> datasets
>>
with ~ 255 variables each + a unique identifier so the dataset can be
>> re-merged in the end, but I was not sure how to select for
variables
>> 1-256,
>> 257-512, etc in the
datastep.
>>
>> I tried breaking it up by variable
first letter, but I want to be able
>> to
>> retain
the old order when i remerge. This is what I'm doing right now,
>> but
>> as you can see the original variable ordering
will be lost when I merge
>> by
>> SURIDM. Is there
any other way I can break this dataset that would
>>
preserve
>> the ordering, or am I doomed to this?
>>
>>
>>
>> *data* _MSMchunk1;
>>
>> set nhbsmsm;
>>
>> keep
SURIDM A: B: C: D: E: F: ;
>>
>> *run*;
>>
>>
>>
>> *data* _MSMchunk2;
>>
>> set nhbsmsm;
>>
>> keep
SURIDM G: H: I: J: K: L: Q: R:;
>>
>> *run*;
>>
>>
>>
>> *data* _MSMchunk3;
>>
>> set nhbsmsm;
>>
>> keep
SURIDM M: N: O: ;
>>
>> *run*;
>>
>> *data* _MSMchunk4;
>>
>> set
nhbsmsm;
>>
>> keep SURIDM P: S: T: U: V: W: Y: Z:
;
>>
>> *run*;
>>
>>
>>
>> *proc* *sort* data=_msmchunk1; by suridm;
>>
>> *proc* *sort* data=_msmchunk2; by suridm;
>>
>> *proc* *sort* data=_msmchunk3; by suridm;
>>
>> *proc* *sort* data=_msmchunk4; by suridm;
>>
>> *run*;
>>
>>
>>
>>
>>
>> *data* merged;
>>
>> merge _msmchunk1 _msmchunk2 _msmchunk3
_msmchunk4;
>>
>> by suridm;
>>
>> *run*;
>>
>> Thanks, guys!
>>
>> Rieza
>>
>
--
Michael L. Davis
Ambler PA
E-Mail:
michael.davis@alumni.duke.edu
|