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,,
;
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.
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;
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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.