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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: