BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
byeh2017
Quartz | Level 8

I have a dataset that has a list of date ranges from a variable called "dcdeathdate". I would like to limit it to Jan 1st 2017 to Feb 28th 2017. I use the following code and it would not work.

 

data janfeb.datesspec;
set janfeb.janfebvarmod;
	if dcdeathdate < mdy(01,01,2017) then delete;
	if dcdeathdate > mdy(02,28,2017) then delete;
run;

 

Here's the sample dataset

 

data JANFEB.SAMPLESAS;
  infile datalines dsd truncover;
  input dcdeathdate:DATETIME16. nationalid:$24. HCVScreening:$9. HCVresult:$27.;
datalines4;
02JAN17:00:00:00,61009030817,Yes,Negative
03JAN17:00:00:00,40001035344,Yes,Negative
03JAN17:00:00:00,12301107155,Yes,Negative
03JAN17:00:00:00,61006025798,Yes,Negative
03JAN17:00:00:00,33001047104,Yes,Negative
03JAN17:00:00:00,61007000494,Yes,Negative
03JAN17:00:00:00,61001066538,Yes,Negative
04JAN17:00:00:00,61004056218,Yes,Negative
05JAN17:00:00:00,61005011122,Yes,Negative
05JAN17:00:00:00,61001073560,Yes,Negative
04JAN17:00:00:00,61004058102,Yes,Negative
04JAN17:00:00:00,61001083691,Yes,Negative
06JAN17:00:00:00,61609034324,Yes,Negative
01JAN17:00:00:00,61006057544,Yes,Negative
04JAN17:00:00:00,61006027847,Yes,Negative
04JAN17:00:00:00,47001046248,Yes,Negative
04JAN17:00:00:00,33001043903,Yes,Negative
01JAN17:00:00:00,21001033914,Yes,Negative
01JAN17:00:00:00,56001023262,Yes,Negative
07JAN17:00:00:00,61001052514,Yes,Negative
02JAN17:00:00:00,54001057453,Yes,Negative
01JAN17:00:00:00,54001033500,Yes,Negative
01JAN17:00:00:00,54001048306,Yes,Negative
01JAN17:00:00:00,54001002655,Yes,Negative
02JAN17:00:00:00,54001050638,Yes,Negative
03JAN17:00:00:00,54001035443,Yes,Negative
02JAN17:00:00:00,54001026613,Yes,Negative
04JAN17:00:00:00,54001043440,Yes,Negative
02JAN17:00:00:00,54001030300,Yes,Negative
04JAN17:00:00:00,54001024199,Yes,Negative
04JAN17:00:00:00,54001033961,Yes,Negative
03JAN17:00:00:00,54750003030,Yes,Negative
04JAN17:00:00:00,54650002459,Yes,Negative
05JAN17:00:00:00,54450002965,Yes,Negative
05JAN17:00:00:00,54001046156,Yes,Negative
08JAN17:00:00:00,31001008869,Yes,Negative
02JAN17:00:00:00,53001059264,Yes,Negative
03JAN17:00:00:00,17001030838,Yes,Negative
03JAN17:00:00:00,60450050088,No,
03JAN17:00:00:00,21001035458,Yes,Negative
03JAN17:00:00:00,60001133497,Yes,Negative
04JAN17:00:00:00,62013000750,Yes,Negative
03JAN17:00:00:00,60350023266,No,
04JAN17:00:00:00,60350049582,No,
05JAN17:00:00:00,56001021291,Yes,Negative
05JAN17:00:00:00,60350050046,No,
02JAN17:00:00:00,53001006283,Yes,Negative
01JAN17:00:00:00,26001021610,01,02
02JAN17:00:00:00,40001002963,Yes,Negative
02JAN17:00:00:00,40001036105,Yes,Negative
01JAN17:00:00:00,01016007752,Yes,Negative
02JAN17:00:00:00,01003014737,Yes,Negative
02JAN17:00:00:00,25001044101,Yes,Negative
01JAN17:00:00:00,01017032355,Yes,Negative
03JAN17:00:00:00,62007012811,Yes,Negative
02JAN17:00:00:00,61601091933,No,Negative
03JAN17:00:00:00,61008017940,No,Negative
04JAN17:00:00:00,61001077448,No,Negative
03JAN17:00:00:00,32901030912,No,Negative
04JAN17:00:00:00,61008017410,No,Negative
02JAN17:00:00:00,37001052489,Yes,Negative
01JAN17:00:00:00,37001050822,Yes,Negative
01JAN17:00:00:00,60001067242,Yes,Negative
01JAN17:00:00:00,62001008421,Yes,Positive
01JAN17:00:00:00,17001016452,Yes,Negative
01JAN17:00:00:00,02001016868,Yes,Negative
01JAN17:00:00:00,26001012712,Yes,Negative
01JAN17:00:00:00,60001096862,Yes,Negative
01JAN17:00:00:00,62004017174,Yes,Negative
01JAN17:00:00:00,01013002451,Yes,Negative
03JAN17:00:00:00,53001049071,Yes,Negative
03JAN17:00:00:00,26001005685,Yes,Negative
03JAN17:00:00:00,29001032044,Yes,Negative
03JAN17:00:00:00,02001007836,Yes,Negative
03JAN17:00:00:00,39001027505,Yes,Negative
03JAN17:00:00:00,55001021898,Yes,Negative
02JAN17:00:00:00,37001024997,Yes,Negative
02JAN17:00:00:00,48001015445,Yes,Negative
02JAN17:00:00:00,19001049337,Yes,Negative
03JAN17:00:00:00,51001022180,Yes,Positive
03JAN17:00:00:00,18001066923,Yes,Negative
03JAN17:00:00:00,21001006112,Yes,Negative
04JAN17:00:00:00,33001066425,Yes,Negative
04JAN17:00:00:00,60001142037,Yes,Negative
05JAN17:00:00:00,61006025817,Yes,Negative
04JAN17:00:00:00,17001033070,Yes,Negative
04JAN17:00:00:00,17001030112,Yes,Negative
05JAN17:00:00:00,17001003279,Yes,Negative
05JAN17:00:00:00,53001024096,Yes,Negative
04JAN17:00:00:00,60001023215,Yes,Negative
05JAN17:00:00:00,33001038020,Yes,Negative
05JAN17:00:00:00,54650000288,Yes,Negative
05JAN17:00:00:00,34350000056,Yes,Positive
05JAN17:00:00:00,48001015163,Yes,Negative
02JAN17:00:00:00,29001031096,Yes,Negative
02JAN17:00:00:00,54001026383,Yes,Negative
04JAN17:00:00:00,60550011261,Yes,Negative
05JAN17:00:00:00,60001119863,Yes,Negative
05JAN17:00:00:00,49001013705,Yes,Negative
06JAN17:00:00:00,58001025379,Yes,Negative
06JAN17:00:00:00,41801032212,Yes,Negative
06JAN17:00:00:00,39001039352,Yes,Negative
06JAN17:00:00:00,60350000156,Yes,Negative
06JAN17:00:00:00,53001052829,Yes,Negative
06JAN17:00:00:00,60001033994,Yes,Negative
06JAN17:00:00:00,29001008173,Yes,Negative
06JAN17:00:00:00,29001016396,Yes,Negative
06JAN17:00:00:00,60001089496,Yes,Negative
06JAN17:00:00:00,29001017126,Yes,Negative
06JAN17:00:00:00,60001080494,Yes,Negative
06JAN17:00:00:00,60001095567,Yes,Negative
06JAN17:00:00:00,53001005379,Yes,Positive
06JAN17:00:00:00,60001062807,Yes,Negative
04JAN17:00:00:00,60801161960,Yes,Negative
06JAN17:00:00:00,37001054114,Yes,Negative
06JAN17:00:00:00,54001037789,Yes,Negative
06JAN17:00:00:00,60001026455,Yes,Negative
06JAN17:00:00:00,53001002545,Yes,Negative
08JAN17:00:00:00,60001031053,Yes,Negative
08JAN17:00:00:00,21001027850,No,
09JAN17:00:00:00,60001088492,Yes,Negative
09JAN17:00:00:00,17001025174,Yes,Negative
09JAN17:00:00:00,21901044267,Yes,Negative
07JAN17:00:00:00,60001101658,Yes,Negative
09JAN17:00:00:00,60350013412,Yes,Negative
07JAN17:00:00:00,29001004492,Yes,Negative
07JAN17:00:00:00,26001029583,Yes,Negative
07JAN17:00:00:00,60001034398,Yes,Negative
07JAN17:00:00:00,21001027582,Yes,Negative
07JAN17:00:00:00,54001052070,Yes,Negative
08JAN17:00:00:00,19001050036,Yes,Negative
08JAN17:00:00:00,55001014547,Yes,Negative
09JAN17:00:00:00,56001006814,Yes,Negative
09JAN17:00:00:00,60001072488,Yes,Negative
09JAN17:00:00:00,19001058154,Yes,Negative
09JAN17:00:00:00,19001066458,Yes,Negative
06JAN17:00:00:00,60750028364,Yes,Negative
07JAN17:00:00:00,62009003541,Yes,Negative
06JAN17:00:00:00,60001039686,Yes,Negative
10JAN17:00:00:00,53001020668,Yes,Negative
06JAN17:00:00:00,55001012370,Yes,Negative
10JAN17:00:00:00,55001016143,Yes,Negative
10JAN17:00:00:00,60001067494,Yes,Negative
05JAN17:00:00:00,53001022947,Yes,Positive
10JAN17:00:00:00,18250006495,Yes,Negative
07JAN17:00:00:00,60401169143,Yes,Negative
09JAN17:00:00:00,62004024350,Yes,Negative
09JAN17:00:00:00,26001032306,Yes,Negative
09JAN17:00:00:00,60001045447,Yes,Negative
09JAN17:00:00:00,21001039514,Yes,Negative
09JAN17:00:00:00,37001058293,Yes,Negative
09JAN17:00:00:00,60003012263,Yes,Negative
07JAN17:00:00:00,60950005599,Yes,Negative
06JAN17:00:00:00,60901163357,Yes,Negative
07JAN17:00:00:00,18001013721,Yes,Negative
07JAN17:00:00:00,60002005030,Yes,Negative
07JAN17:00:00:00,42001013310,Yes,Positive
03JAN17:00:00:00,55001020098,Yes,Negative
07JAN17:00:00:00,33001080088,Yes,Negative
04JAN17:00:00:00,60401171465,Yes,Negative
07JAN17:00:00:00,62005025475,Yes,Negative
07JAN17:00:00:00,29001015089,Yes,Negative
10JAN17:00:00:00,62002007047,Yes,Negative
10JAN17:00:00:00,38001047365,Yes,Negative
10JAN17:00:00:00,53001052381,Yes,Negative
10JAN17:00:00:00,62001002141,Yes,Negative
10JAN17:00:00:00,19001074511,Yes,Negative
10JAN17:00:00:00,37001015975,Yes,Negative
10JAN17:00:00:00,37001038228,Yes,Negative
08JAN17:00:00:00,39450008328,Yes,Negative
05JAN17:00:00:00,49001014679,Yes,Negative
03JAN17:00:00:00,53001042377,Yes,Positive
03JAN17:00:00:00,37001022213,Yes,Negative
04JAN17:00:00:00,49001005836,No,
04JAN17:00:00:00,48001021577,Yes,Negative
04JAN17:00:00:00,60001110257,No,
05JAN17:00:00:00,55001013700,No,
06JAN17:00:00:00,41001008969,Yes,Negative
06JAN17:00:00:00,19001072588,Yes,Positive
06JAN17:00:00:00,17001025437,No,
07JAN17:00:00:00,51001019825,Yes,Negative
07JAN17:00:00:00,58001024813,No,
07JAN17:00:00:00,60001132085,Yes,Negative
07JAN17:00:00:00,53001037330,Yes,Negative
08JAN17:00:00:00,41001003669,Yes,Negative
08JAN17:00:00:00,21001028315,Yes,Negative
08JAN17:00:00:00,60001159843,Yes,Negative
09JAN17:00:00:00,60001058815,Yes,Negative
10JAN17:00:00:00,58001012621,Yes,Negative
10JAN17:00:00:00,18001023501,Yes,Negative
10JAN17:00:00:00,42001029315,Yes,Negative
05JAN17:00:00:00,01011094651,Yes,Negative
05JAN17:00:00:00,24001045773,Yes,Negative
04JAN17:00:00:00,37001020655,Yes,Negative
01JAN17:00:00:00,01030041913,Yes,Negative
02JAN17:00:00:00,24001040015,No,
02JAN17:00:00:00,16001013481,No,
02JAN17:00:00:00,01030034930,No,
03JAN17:00:00:00,01019045369,Yes,Negative
03JAN17:00:00:00,60001022570,Yes,Negative
03JAN17:00:00:00,00000000000,No,
03JAN17:00:00:00,01018004156,No,
04JAN17:00:00:00,01030036035,Yes,Negative
04JAN17:00:00:00,01024015247,Yes,Negative
05JAN17:00:00:00,01030038915,No,
05JAN17:00:00:00,01007000179,No,
05JAN17:00:00:00,01020014076,No,
05JAN17:00:00:00,01007001228,Yes,Negative
06JAN17:00:00:00,59001022609,Yes,Negative
06JAN17:00:00:00,01005038283,No,
06JAN17:00:00:00,01030005223,No,
06JAN17:00:00:00,01034002494,Yes,Negative
07JAN17:00:00:00,01030039074,Yes,Negative
07JAN17:00:00:00,01008037441,Yes,Negative
07JAN17:00:00:00,56001004342,Yes,Negative
07JAN17:00:00:00,43001020658,Yes,Negative
07JAN17:00:00:00,24001028635,Yes,Negative
08JAN17:00:00:00,01008006945,Yes,Negative
01JAN17:00:00:00,01013029713,Yes,Negative
02JAN17:00:00:00,01005016741,Yes,Negative
02JAN17:00:00:00,01009023303,Yes,Negative
03JAN17:00:00:00,13001025483,Yes,Negative
03JAN17:00:00:00,34001001000,Yes,Negative
03JAN17:00:00:00,01005007208,Yes,Negative
03JAN17:00:00:00,01030042340,Yes,Negative
04JAN17:00:00:00,01008035645,Yes,Negative
04JAN17:00:00:00,01005005358,Yes,Negative
04JAN17:00:00:00,01017000990,Yes,Negative
05JAN17:00:00:00,61003003151,Yes,Negative
05JAN17:00:00:00,62003007034,Yes,Negative
06JAN17:00:00:00,01012026839,Yes,Negative
06JAN17:00:00:00,01030041029,Yes,Negative
06JAN17:00:00:00,62001017594,Yes,Negative
06JAN17:00:00:00,01008031304,Yes,Negative
06JAN17:00:00:00,01030039791,Yes,Negative
06JAN17:00:00:00,01034005287,Yes,Negative
06JAN17:00:00:00,01010016880,Yes,Negative
06JAN17:00:00:00,35001055799,Yes,Negative
06JAN17:00:00:00,01030002732,Yes,Negative
06JAN17:00:00:00,01034001599,Yes,Negative
06JAN17:00:00:00,01030043913,No,
06JAN17:00:00:00,60001143746,No,
06JAN17:00:00:00,42001009597,No,
06JAN17:00:00:00,01030017920,No,
06JAN17:00:00:00,01024047795,No,
06JAN17:00:00:00,01030040432,No,
07JAN17:00:00:00,13001031953,Yes,Negative
07JAN17:00:00:00,01015018705,Yes,Negative
07JAN17:00:00:00,01030017059,No,
08JAN17:00:00:00,01009005673,Yes,Negative
08JAN17:00:00:00,01005015994,Yes,Negative
08JAN17:00:00:00,59004004315,Yes,Negative
08JAN17:00:00:00,01030042321,Yes,Negative
08JAN17:00:00:00,01030005005,Yes,Negative
08JAN17:00:00:00,17001005496,Yes,Negative
08JAN17:00:00:00,01008020435,Yes,Negative
08JAN17:00:00:00,62006000733,Yes,Negative
08JAN17:00:00:00,01001030578,Yes,Negative
08JAN17:00:00:00,25001026281,Yes,Negative
08JAN17:00:00:00,26001017447,No,
08JAN17:00:00:00,01005000519,No,
08JAN17:00:00:00,34001007354,No,
08JAN17:00:00:00,19001100100,Yes,Negative
08JAN17:00:00:00,22201025307,Yes,Negative
09JAN17:00:00:00,01008025048,Yes,Negative
09JAN17:00:00:00,22001014282,Yes,Negative
09JAN17:00:00:00,01002006271,Yes,Negative
09JAN17:00:00:00,01008001431,Yes,Negative
09JAN17:00:00:00,01030048855,Yes,Negative
09JAN17:00:00:00,01013002507,Yes,Negative
10JAN17:00:00:00,01030029358,Yes,Negative
10JAN17:00:00:00,01005033234,Yes,Negative
10JAN17:00:00:00,01030011614,Yes,Negative
10JAN17:00:00:00,01017029220,Yes,Negative
11JAN17:00:00:00,31001012247,Yes,Negative
11JAN17:00:00:00,31001039588,Yes,Negative
11JAN17:00:00:00,04001002041,Yes,Negative
05JAN17:00:00:00,01030043991,Yes,Negative
03JAN17:00:00:00,17001015908,Yes,Negative
05JAN17:00:00:00,60001075332,Yes,Negative
02JAN17:00:00:00,01025018306,Yes,Negative
03JAN17:00:00:00,65041000414,Yes,Negative
03JAN17:00:00:00,01150036926,Yes,Negative
03JAN17:00:00:00,01301125578,Yes,Negative
03JAN17:00:00:00,55001005553,Yes,Negative
03JAN17:00:00:00,62001001717,Yes,Negative
04JAN17:00:00:00,01711099663,Yes,Negative
04JAN17:00:00:00,24001037170,Yes,Negative
04JAN17:00:00:00,02001005954,Yes,Negative
03JAN17:00:00:00,01005031797,Yes,Negative
03JAN17:00:00:00,01201123141,Yes,Negative
05JAN17:00:00:00,01950001292,Yes,Negative
05JAN17:00:00:00,01019003028,Yes,Negative
03JAN17:00:00:00,01324098808,Yes,Negative
03JAN17:00:00:00,23001012499,Yes,Negative
03JAN17:00:00:00,01417059942,Yes,Negative
03JAN17:00:00:00,59150011328,Yes,Negative
04JAN17:00:00:00,12001063677,Yes,Negative
04JAN17:00:00:00,18001013999,Yes,Negative
04JAN17:00:00:00,,Yes,Negative
04JAN17:00:00:00,57001050401,Yes,Negative
04JAN17:00:00:00,01021012875,Yes,Negative
04JAN17:00:00:00,30001009052,Yes,Negative
04JAN17:00:00:00,12001077481,Yes,Negative
01JAN17:00:00:00,01001068199,Yes,Negative
06JAN17:00:00:00,01453012610,Yes,Negative
06JAN17:00:00:00,01009021179,Yes,Negative
06JAN17:00:00:00,01017011953,Yes,Negative
06JAN17:00:00:00,01007004682,Yes,Negative
06JAN17:00:00:00,01450113403,Yes,Negative
06JAN17:00:00:00,01750050612,Yes,Negative
06JAN17:00:00:00,36301058346,Yes,Negative
07JAN17:00:00:00,01025022037,Yes,Negative
07JAN17:00:00:00,29350001038,Yes,Negative
07JAN17:00:00:00,01950073298,Yes,Negative
07JAN17:00:00:00,01008025971,Yes,Negative
07JAN17:00:00:00,01450034617,Yes,Negative
07JAN17:00:00:00,01017052247,Yes,Negative
07JAN17:00:00:00,01150082917,Yes,Negative
08JAN17:00:00:00,01019077392,Yes,Negative
08JAN17:00:00:00,29850001039,Yes,Negative
08JAN17:00:00:00,12001070412,Yes,Negative
08JAN17:00:00:00,01954004331,Yes,Negative
08JAN17:00:00:00,01001053659,Yes,Negative
01JAN17:00:00:00,55001017228,Yes,Negative
01JAN17:00:00:00,01016006777,Yes,Negative
01JAN17:00:00:00,01201114124,Yes,Negative
01JAN17:00:00:00,01002010333,Yes,Negative
01JAN17:00:00:00,01450102291,Yes,Negative
01JAN17:00:00:00,01308066341,Yes,Negative
01JAN17:00:00:00,45001020691,Yes,Negative
01JAN17:00:00:00,35001032972,Yes,Negative
10JAN17:00:00:00,01001065972,Yes,Negative
09JAN17:00:00:00,01350081754,Yes,Negative
09JAN17:00:00:00,43001019918,Yes,Negative
12JAN17:00:00:00,01950077300,Yes,Negative
01JAN17:00:00:00,35001122351,Yes,Negative
09JAN17:00:00:00,60350015557,Yes,Negative
01JAN17:00:00:00,35031004659,Yes,Negative
09JAN17:00:00:00,01030042142,Yes,Negative
09JAN17:00:00:00,01011032686,Yes,Negative
01JAN17:00:00:00,01450049131,Yes,Negative
01JAN17:00:00:00,35001125909,Yes,Negative
09JAN17:00:00:00,01250068377,Yes,Negative
09JAN17:00:00:00,01650083766,Yes,Negative
02JAN17:00:00:00,13001016799,Yes,Negative
02JAN17:00:00:00,01419092976,Yes,Negative
02JAN17:00:00:00,47350003387,Yes,Negative
09JAN17:00:00:00,01027075570,Yes,Negative
02JAN17:00:00:00,01009014635,Yes,Negative
03JAN17:00:00:00,,Yes,Negative
08JAN17:00:00:00,31001040187,Yes,Negative
09JAN17:00:00:00,01024000849,Yes,Negative
03JAN17:00:00:00,24001018768,Yes,Negative
03JAN17:00:00:00,01024001981,Yes,Negative
10JAN17:00:00:00,35001095287,Yes,Negative
10JAN17:00:00:00,01450108367,Yes,Negative
10JAN17:00:00:00,13250003328,Yes,Negative
10JAN17:00:00:00,54001012331,Yes,Negative
10JAN17:00:00:00,01024046150,Yes,Negative
12JAN17:00:00:00,20750009979,Yes,Negative
11JAN17:00:00:00,01650124640,Yes,Negative
11JAN17:00:00:00,01010015695,Yes,Negative
08JAN17:00:00:00,62014003068,Yes,Negative
10JAN17:00:00:00,60001139281,Yes,Negative
12JAN17:00:00:00,01034000410,Yes,Negative
11JAN17:00:00:00,01650112540,Yes,Negative
12JAN17:00:00:00,62102011328,Yes,Negative
12JAN17:00:00:00,59001076130,Yes,Negative
12JAN17:00:00:00,53650000538,Yes,Negative
05JAN17:00:00:00,36001021514,Yes,Negative
01JAN17:00:00:00,62006000579,No,
05JAN17:00:00:00,60001129604,Yes,Negative
03JAN17:00:00:00,61001040505,Yes,Negative
03JAN17:00:00:00,60001065198,Yes,Negative
01JAN17:00:00:00,62006020616,Yes,Negative
01JAN17:00:00:00,09001024026,Yes,Positive
09JAN17:00:00:00,55001006257,Yes,Negative
01JAN17:00:00:00,55001021342,Yes,Negative
03JAN17:00:00:00,27001004379,Yes,Negative
01JAN17:00:00:00,53001034959,Yes,Negative
01JAN17:00:00:00,21001024214,Yes,Negative
03JAN17:00:00:00,62003007720,Yes,Negative
06JAN17:00:00:00,01354004439,Yes,Negative
06JAN17:00:00:00,33001075520,Yes,Negative
06JAN17:00:00:00,61006014724,Yes,Negative
06JAN17:00:00:00,61006015264,Yes,Negative
06JAN17:00:00:00,61806082288,Yes,Negative
10JAN17:00:00:00,61006078096,Yes,Negative
10JAN17:00:00:00,61850018368,Yes,Negative
10JAN17:00:00:00,33550001696,Yes,Negative
10JAN17:00:00:00,61350006327,Yes,Negative
10JAN17:00:00:00,61651000961,Yes,Negative
10JAN17:00:00:00,61850014997,Yes,Negative
10JAN17:00:00:00,61006077716,Yes,Negative
11JAN17:00:00:00,61004017580,Yes,Negative
11JAN17:00:00:00,61650017716,Yes,Negative
11JAN17:00:00:00,62002007362,Yes,Negative
13JAN17:00:00:00,61010019731,Yes,Negative
13JAN17:00:00:00,61750011132,Yes,Negative
13JAN17:00:00:00,61701093721,Yes,Negative
13JAN17:00:00:00,61650004190,Yes,Negative
13JAN17:00:00:00,61201090396,Yes,Negative
13JAN17:00:00:00,61010016748,Yes,Negative
13JAN17:00:00:00,33001020557,Yes,Negative
14JAN17:00:00:00,61350004091,Yes,Negative
14JAN17:00:00:00,61650000682,Yes,Negative
14JAN17:00:00:00,61655000149,Yes,Negative
14JAN17:00:00:00,61006078915,Yes,Negative
14JAN17:00:00:00,61001013907,Yes,Negative
15JAN17:00:00:00,01350071760,Yes,Negative
15JAN17:00:00:00,01011034259,Yes,Negative
15JAN17:00:00:00,01150060333,Yes,Negative
15JAN17:00:00:00,01025007931,Yes,Negative
15JAN17:00:00:00,01354003288,Yes,Negative
15JAN17:00:00:00,61009027496,Yes,Negative
14JAN17:00:00:00,01150102304,Yes,Negative
13JAN17:00:00:00,01950095553,Yes,Negative
13JAN17:00:00:00,62006063122,Yes,Negative
15JAN17:00:00:00,01027068670,Yes,Negative
06JAN17:00:00:00,01009003555,Yes,Negative
09JAN17:00:00:00,12001075219,Yes,Negative
04JAN17:00:00:00,01030001883,Yes,Negative
09JAN17:00:00:00,40001011645,Yes,Negative
11JAN17:00:00:00,06001002386,Yes,Negative
06JAN17:00:00:00,01009001056,Yes,Negative
05JAN17:00:00:00,01009001313,Yes,Negative
06JAN17:00:00:00,62001027018,Yes,Negative
11JAN17:00:00:00,62003006060,Yes,Negative
05JAN17:00:00:00,01024043162,Yes,Negative
04JAN17:00:00:00,01013022123,Yes,Negative
12JAN17:00:00:00,37001047511,Yes,Negative
09JAN17:00:00:00,10001038984,Yes,Negative
16JAN17:00:00:00,18650005476,Yes,Negative
16JAN17:00:00:00,01250061763,Yes,Negative
16JAN17:00:00:00,01650003928,Yes,Negative
16JAN17:00:00:00,01350092656,Yes,Negative
14JAN17:00:00:00,01850079273,Yes,Negative
14JAN17:00:00:00,15001023304,Yes,Negative
16JAN17:00:00:00,01353008700,Yes,Negative
16JAN17:00:00:00,01019005523,Yes,Negative
13JAN17:00:00:00,12001049718,Yes,Negative
13JAN17:00:00:00,01750099660,Yes,Negative
13JAN17:00:00:00,01015000998,Yes,Negative
13JAN17:00:00:00,60401164844,Yes,Negative
13JAN17:00:00:00,60550017787,Yes,Negative
13JAN17:00:00:00,01030028879,Yes,Positive
09JAN17:00:00:00,61150029775,Yes,Negative
17JAN17:00:00:00,01550104168,Yes,Negative
09JAN17:00:00:00,28001079946,Yes,Negative
10JAN17:00:00:00,01021012880,Yes,Negative
09JAN17:00:00:00,18601074927,Yes,Negative
06JAN17:00:00:00,01550090155,Yes,Negative
11JAN17:00:00:00,01001022702,Yes,Negative
09JAN17:00:00:00,08001023471,Yes,Negative
03JAN17:00:00:00,01004007600,Yes,Negative
17JAN17:00:00:00,35001003042,Yes,Negative
17JAN17:00:00:00,62809013908,Yes,Negative
17JAN17:00:00:00,01650109819,Yes,Negative
17JAN17:00:00:00,07001023953,Yes,Negative
17JAN17:00:00:00,01317065103,Yes,Negative
17JAN17:00:00:00,01550085350,Yes,Negative
17JAN17:00:00:00,01007013582,Yes,Negative
17JAN17:00:00:00,01250094830,Yes,Negative
12JAN17:00:00:00,01030009676,Yes,Negative
12JAN17:00:00:00,11001013118,Yes,Negative
12JAN17:00:00:00,18001018489,Yes,Negative
12JAN17:00:00:00,22001014394,Yes,Negative
12JAN17:00:00:00,01030027670,Yes,Negative
12JAN17:00:00:00,01012002158,Yes,Negative
12JAN17:00:00:00,01034004873,Yes,Negative
12JAN17:00:00:00,01008025066,Yes,Negative
12JAN17:00:00:00,01008017861,Yes,Negative
12JAN17:00:00:00,01024004861,Yes,Negative
12JAN17:00:00:00,59002006466,Yes,Negative
12JAN17:00:00:00,01019066224,Yes,Negative
12JAN17:00:00:00,62001007871,Yes,Negative
12JAN17:00:00:00,16001011907,Yes,Negative
12JAN17:00:00:00,01011097042,Yes,Negative
12JAN17:00:00:00,01011096361,Yes,Negative
12JAN17:00:00:00,01019044789,No,
12JAN17:00:00:00,61001039707,No,
12JAN17:00:00:00,01030008792,No,
13JAN17:00:00:00,09001011634,Yes,Negative
13JAN17:00:00:00,09001011634,Yes,Negative
13JAN17:00:00:00,01030032722,Yes,Negative
13JAN17:00:00:00,01001034940,Yes,Negative
13JAN17:00:00:00,62004024255,Yes,Negative
13JAN17:00:00:00,62003004574,Yes,Negative
13JAN17:00:00:00,01030025407,Yes,Negative
13JAN17:00:00:00,01030035060,Yes,Negative
13JAN17:00:00:00,41001022340,Yes,Negative
13JAN17:00:00:00,12001088817,Yes,Negative
13JAN17:00:00:00,28001115969,Yes,Negative
13JAN17:00:00:00,01023012591,Yes,Negative
13JAN17:00:00:00,01011074010,No,
13JAN17:00:00:00,01021003986,No,
13JAN17:00:00:00,01010005494,No,
13JAN17:00:00:00,01013014284,No,
14JAN17:00:00:00,01030046360,Yes,Negative
;;;;

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Rohit12
Obsidian | Level 7
data janfeb.datesspec;
set janfeb.janfebvarmod;
	if dcdeathdate < dhms(mdy(01,01,2017),0,0,0) then delete;
	if dcdeathdate > dhms(mdy(02,28,2017),0,0,0) then delete;
run;

this  is how you can use DHMS function .Your code will delete all the rows which are less than01jan2017  and greater than 28jan2017 

View solution in original post

5 REPLIES 5
Rohit12
Obsidian | Level 7

Hello 

 

As SAS stores date and datetime value as integers .You are using 

 

if dcdeathdate < mdy(01,01,2017) then delete;
	if dcdeathdate > mdy(02,28,2017) then delete;

In your case dcdeathdate is datetime  and mdy fuction creates date .So u need to convert  value comimg from mdy fuction to  datetime by using DHMS function .Then u can use comparsion between values

 

In sas 02JAN17:00:00:00 and 02Jan17 will have different integer  value when it is stored 

 

 

byeh2017
Quartz | Level 8

I also tried this code and it didn't work:

 

data janfeb.datesspec;
set janfeb.janfebvarmod;
	if dcdeathdate < DATETIME16(01JAN17:00:00:00) then delete;
	if dcdeathdate > DATETIME16(28FEB17:00:00:00) then delete;
run;

It gave me this error:

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         data janfeb.datesspec;
 63         set janfeb.janfebvarmod;
 64         if dcdeathdate < DATETIME16(01JAN17:00:00:00) then delete;
                              __________   _____
                              68           388
                                           76
 65         if dcdeathdate > DATETIME16(28FEB17:00:00:00) then delete;
                              __________   _____
                              68           388
                                           76
 ERROR 68-185: The function DATETIME16 is unknown, or cannot be accessed.
 
 ERROR 388-185: Expecting an arithmetic operator.
 
 ERROR 76-322: Syntax error, statement will be ignored.
 
 66         run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set JANFEB.DATESSPEC may be incomplete.  When this step was stopped there were 0 observations and 43 variables.
 WARNING: Data set JANFEB.DATESSPEC was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.13 seconds
       cpu time            0.13 seconds
       
 
 67         
 68         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 81         
byeh2017
Quartz | Level 8

Thank you,

 

how do i use the DHMS function to convert datetime?

Rohit12
Obsidian | Level 7
data janfeb.datesspec;
set janfeb.janfebvarmod;
	if dcdeathdate < dhms(mdy(01,01,2017),0,0,0) then delete;
	if dcdeathdate > dhms(mdy(02,28,2017),0,0,0) then delete;
run;

this  is how you can use DHMS function .Your code will delete all the rows which are less than01jan2017  and greater than 28jan2017 

ballardw
Super User

Your example data is a pet peeve of mine. Apparently your data is actually only a date but is stored as datetime, which caused you some confusion. If ALL of the "time" values of a "datetime" variable you might consider ignoring the time component.

 

data SAMPLESAS;
  infile datalines dsd truncover ;
  informat  dcdeathdate DATE7. nationalid $24. HCVScreening $9. HCVresult $27.;
  input dcdeathdate nationalid HCVScreening HCVresult;
  format dcdeathdate date9.;
datalines4;
02JAN17:00:00:00,61009030817,Yes,Negative
03JAN17:00:00:00,40001035344,Yes,Negative
03JAN17:00:00:00,12301107155,Yes,Negative
03JAN17:00:00:00,61006025798,Yes,Negative
03JAN17:00:00:00,33001047104,Yes,Negative
03JAN17:00:00:00,61007000494,Yes,Negative
03JAN17:00:00:00,61001066538,Yes,Negative
04JAN17:00:00:00,61004056218,Yes,Negative
05JAN17:00:00:00,61005011122,Yes,Negative
;;;;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 5 replies
  • 3914 views
  • 0 likes
  • 3 in conversation