BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8

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,,  










;

3 REPLIES 3
LinusH
Tourmaline | Level 20

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
Tom
Super User Tom
Super User

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;

AUTigers
Calcite | Level 5

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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1597 views
  • 1 like
  • 4 in conversation