Tilde, dlm and colon format modifier in input list
There are 3 concepts that I would like to clarify. :(colon format modifier)
, ~(tilde)
anddlm=
data scores;
infile datalines dsd;
input name : $10. score1-score3 team ~ $25. div $;
datalines;
Smith,12,22,46,"Green Hornets, Atlanta",AAA
FriedmanLi,23,19,25,"High Volts, Portland",AAA
Jones,09,17,54,"Vulcans, Las Vegas",AA
;
run;
First, using :
input in an instruction can completely replace the instruction length
? And why don't I need :
sth for command variable like team : ~ $25.
?
Second, why can sas automatically recoginize to ,
be a delimiter but not "
or blank
?
source to share
- The Colon statement is required to tell SAS to use the provided informat, but stop reading the value for this variable when a delimiter is encountered . Don't forget the colons, because without them SAS can read behind the separator to match the width specified in the info file.
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000144370.htm
-
~
The tilde is required to handle single quotes, double quotes, and delimiters in character values ββin a special way. This format modifier reads the delimiters in the specified character values ββas characters instead of delimiters, and preserves quotes when the value is written to a variable.
Why is this necessary because SAS has reserved certain delimiters for its own operation, i.e. single quotes, double quotes are used to represent strings, when you want SAS to handle these quotes differently you must explicitly tell this to SAS using - Tilde ( ~
)
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000144370.htm
-
SAS can automatically recognize a single
blank
as a delimiter and cannot automatically recognize,
a delimiter. You will need to explicitly specify it to SAS. In your case, you used an optiondsd
that does three things for you.-
(i) It automatically takes
,
as your delimiter by default . If you want to provide any other delimiter, you will need to specify it in SAS, then using the optiondlm=
. -
(Ii) SAS treats two consecutive delimiters as missing values ββand removes quotes from character values
-
(iii) indicates that when data values ββare quoted, delimiters within the value are treated as character data
-
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146932.htm
source to share