DATA Step, Macro, Functions and more

Cant create ENCType with quotes

Reply
Super Contributor
Posts: 647

Cant create ENCType with quotes

If i dont use : after only then enctype is coming in with quotes.

data sample;


infile datalines dlm=',' dsd


input PatID : $9.  EncounterID :$16.  ADate :MMDDYY10. Provider: $16.   EncType  $4.


$7. PX_Codetype : $2.  OrigPX :$7.;


format ADate MMDDYY10.;


datalines;



PATID1,ENC1,11/07/2010,710826,'IP',3813,C4,,   


PATID1,ENC2,02/08/2011,710826,'IP',3813,C4,,   


PATID2,ENC1,11/02/2010,710826,'ED',4291,C4,,                    


PATID2,ENC2,12/19/2010,710826,'IP',3813,C4,,     


PATID2,ENC3,02/27/2011,710826,'IP',3813,C4,,   


PATID3,ENC1,09/28/2010,710826,'ED',4291,C4,,                    


PATID3,ENC2,11/04/2010,710826,'IP',3813,C4,, 


PATID3,ENC3,12/19/2010,710826,'AV',3812,C4,,  


PATID3,ENC4,03/04/2011,710826,'AV',3813,C4,,  










;

Super User
Posts: 5,256

Re: Cant create ENCType with quotes

What is the question?

I assume you want to get rid of the ' sorrounding your EncType.

Just add

enctype = compress(enctype,"'");

just before the datalines.

Data never sleeps
Super User
Super User
Posts: 6,499

Re: Cant create ENCType with quotes

When you do not use the : modifier SAS takes the lengths of the informats specified in the INPUT statement literally and this causes it to "eat" the delimiters.

A better way is the use an ATTRIB or LENGTH statement to define the lengths of your variables and not to embed this information into the INPUT statement.

data sample;

  infile datalines dlm=',' dsd;

  attrib PatID length=$9 EncounterID length=$16

         ADate length=8 informat=MMDDYY10. format=yymmdd10.

         Provider length=$16   EncType length= $4

         code length=$7 PX_Codetype length=$2.  OrigPX length=$7.

  ;

  input patid -- origpx;

  put (_all_) (=) ;

datalines;

PATID1,ENC1,11/07/2010,710826,'IP',3813,C4,,

PATID1,ENC2,02/08/2011,710826,'IP',3813,C4,,

PATID2,ENC1,11/02/2010,710826,'ED',4291,C4,,

PATID2,ENC2,12/19/2010,710826,'IP',3813,C4,,

PATID2,ENC3,02/27/2011,710826,'IP',3813,C4,,

PATID3,ENC1,09/28/2010,710826,'ED',4291,C4,,

PATID3,ENC2,11/04/2010,710826,'IP',3813,C4,,

PATID3,ENC3,12/19/2010,710826,'AV',3812,C4,,

PATID3,ENC4,03/04/2011,710826,'AV',3813,C4,,

run;

Contributor
Posts: 21

Re: Cant create ENCType with quotes

are you trying to read it in with quotation marks as part of the value. if yes, you need to use ~ modifier.

data want;

infile datalines dlm=',' dsd;

input PatID : $9.  EncounterID :$16.  ADate :MMDDYY10. Provider: $16.   EncType  ~ :$4.

PX_Codetype : $2.  OrigPX :$7.;

format ADate MMDDYY10.;

datalines;

PATID1,ENC1,11/07/2010,710826,'IP',3813,C4,,

PATID1,ENC2,02/08/2011,710826,'IP',3813,C4,,

PATID2,ENC1,11/02/2010,710826,'ED',4291,C4,,

PATID2,ENC2,12/19/2010,710826,'IP',3813,C4,,

PATID2,ENC3,02/27/2011,710826,'IP',3813,C4,,

PATID3,ENC1,09/28/2010,710826,'ED',4291,C4,,

PATID3,ENC2,11/04/2010,710826,'IP',3813,C4,,

PATID3,ENC3,12/19/2010,710826,'AV',3812,C4,,

PATID3,ENC4,03/04/2011,710826,'AV',3813,C4,,

;

run;

proc print ;run;

Ask a Question
Discussion stats
  • 3 replies
  • 221 views
  • 1 like
  • 4 in conversation