Re: SAS concatenation problem #3

  • Follow


More precisely stated: SAS sets the length of a variable the first time the
compiler sees it, whether it be in dataset 1 or 17.  The fact that field XYZ
is missing has NOTHING to do with setting its length.  It could have have a
length of 32K and be missing and SAS will set the length to 32K if that's
the length of the variable when SAS first sees it.

It's important that the length statement be specified BEFORE the SET
statement, i.e. so it's the first time SAS sees the variable.

data a;
  length XYZ  $16000
         ABC  $4;
  XYZ = ' ';
  ABC = ' ';
run;

data b;
  length XYZ $1
         DEF $8
  ;
  XYZ = ' ';
  DEF = ' ';
run;

data c;
  length XYZ $32000;
  set a b;
run;

proc contents data=c;
run;

#    Variable    Type      Len      Pos
---------------------------------------
2    ABC         Char        4    32000
3    DEF         Char        8    32004
1    XYZ         Char    32000        0

-----Original Message-----
From: Dunn, Toby [mailto:Toby.Dunn@TEA.STATE.TX.US]
Sent: Thursday, September 16, 2004 3:50 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: SAS concatenation problem


Llyod,

The reason you are getting a variable with the length of one is more
than likely the fact that the first data set you bring in the data step
has a missing value for that variable (the first data set is setting the
length of your variables for all the datasets you are brining in.). The
easiest way to solve the problem is to use a length statement and set
the variable(s) to the length you desire.

HTH
Toby Dunn
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Lloyd Dollins
Sent: Thursday, September 16, 2004 2:19 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: SAS concatenation problem

I have a SAS data step that concatenates several files into one.  The
code
looks like this:

data all1; set baseball1 mbasketball1 wbasketball1 mxcntry1 wxcntry1
football1 fhockey1
      mgolf1 wgolf1 menlax1 wmnlax1 msoccer1 wsoccer1 softball1 mswim1
wswim1 mtennis1
      wtennis1 mtrack1 wtrack1 volleyball1 wrowing1 wrestling1 others1;

All of the files have the exact same layout, but one of the text fields
is
null/empty in most of the files.  I notice that the data set that is
created (all1) is exactly the way I expect it to be except for that one
field.  That field has been truncated to 1 character.  Does anyone know
why
this is and what I can do to correct this?

Please reply to my email address.

Thank you,
Lloyd Dollins
dollins@virginia.edu

------------------------------------------------------------
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.

Ce courrier �lectronique est confidentiel et prot�g�. L'exp�diteur ne renonce pas aux droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) d�sign�(s) est interdite. Si vous recevez ce courrier �lectronique par erreur, veuillez m'en aviser imm�diatement, par retour de courrier �lectronique ou par un autre moyen.

============================================================
0
Reply harry.droogendyk1 (872) 9/16/2004 7:59:10 PM


0 Replies
36 Views

(page loaded in 0.024 seconds)

Similiar Articles:













7/29/2012 5:46:24 AM


Reply: