我是SAS的新手,我遇到了问题。我有这样的数据集:
Dataset_idchemo
我想用0 if Chemo = NonTreated else 1
创建一个新的虚拟变量,但idk为什么我不能,结果是一个只有零的列和一堆警告,如" Invalid numeric data, 'Treated' , at line 74 column 13."
我的代码是:
data new;
set readm;
chemio = 0;
if chemo =: 'Treated' then chemio = 1;
run;
谢谢!
PS:这是我的数据集,我不知道这是否是在这里添加它的正确方法,让我知道最好的方法是什么。
有四列Oss
,它是观察的数量,id
,event
(0或1)和chemo
(“已治疗”,“未经治疗”)
Oss id event chemo
1 1 1 Treated
2 1 1 Treated
3 1 0 Treated
4 2 1 NonTreated
5 2 0 NonTreated
6 3 1 NonTreated
7 3 0 NonTreated
8 4 1 Treated
9 4 1 Treated
10 4 1 Treated
11 4 1 Treated
12 4 0 Treated
13 5 1 NonTreated
14 5 0 NonTreated
15 6 1 Treated
16 6 1 Treated
17 6 1 Treated
18 6 0 Treated
19 7 1 Treated
20 7 1 Treated
21 7 1 Treated
22 7 0 Treated
23 8 0 NonTreated
24 9 1 NonTreated
25 9 0 NonTreated
26 10 0 Treated
27 11 1 Treated
28 11 1 Treated
29 11 0 Treated
30 12 0 Treated
31 13 1 NonTreated
32 13 0 NonTreated
33 14 0 Treated
34 15 1 NonTreated
35 15 1 NonTreated
36 15 0 NonTreated
37 16 1 NonTreated
38 16 0 NonTreated
39 17 0 NonTreated
40 18 0 Treated
41 19 0 Treated
42 20 1 Treated
43 20 0 Treated
44 21 1 Treated
45 21 0 Treated
46 22 0 Treated
47 23 1 Treated
48 23 0 Treated
49 24 1 Treated
50 24 0 Treated
51 25 0 Treated
52 26 0 Treated
53 27 0 Treated
54 28 0 NonTreated
55 29 1 Treated
56 29 0 Treated
57 30 0 Treated
58 31 1 Treated
59 31 0 Treated
60 32 1 NonTreated
61 32 1 NonTreated
62 32 0 NonTreated
63 33 1 Treated
64 33 1 Treated
65 33 1 Treated
66 33 0 Treated
67 34 0 Treated
68 35 1 Treated
69 35 0 Treated
70 36 0 Treated
71 37 1 NonTreated
72 37 1 NonTreated
73 37 0 NonTreated
74 38 0 NonTreated
75 39 0 Treated
76 40 1 Treated
77 40 1 Treated
78 40 1 Treated
79 40 1 Treated
80 40 1 Treated
81 40 1 Treated
82 40 0 Treated
83 41 1 Treated
84 41 0 Treated
85 42 1 Treated
86 42 1 Treated
87 42 0 Treated
88 43 1 Treated
89 43 1 Treated
90 43 0 Treated
91 44 1 NonTreated
92 44 0 NonTreated
93 45 0 NonTreated
94 46 0 Treated
95 47 0 NonTreated
96 48 0 NonTreated
97 49 1 NonTreated
98 49 0 NonTreated
99 50 1 NonTreated
100 50 0 NonTreated
101 51 1 NonTreated
102 51 1 NonTreated
103 51 0 NonTreated
104 52 1 NonTreated
105 52 1 NonTreated
106 52 1 NonTreated
107 52 1 NonTreated
108 52 0 NonTreated
109 53 1 Treated
110 53 1 Treated
111 53 0 Treated
112 54 1 NonTreated
113 54 0 NonTreated
114 55 0 Treated
115 56 0 Treated
116 57 0 NonTreated
117 58 0 Treated
118 59 0 Treated
119 60 1 NonTreated
120 60 0 NonTreated
121 61 0 Treated
122 62 0 Treated
123 63 0 Treated
124 64 1 Treated
125 64 0 Treated
126 65 1 Treated
127 65 0 Treated
128 66 0 Treated
129 67 0 NonTreated
130 68 1 NonTreated
131 68 0 NonTreated
132 69 0 Treated
133 70 0 Treated
134 71 1 Treated
135 71 1 Treated
136 71 0 Treated
137 72 0 Treated
138 73 0 Treated
139 74 0 NonTreated
140 75 0 Treated
141 76 1 NonTreated
142 76 1 NonTreated
143 76 0 NonTreated
144 77 0 NonTreated
145 78 1 NonTreated
146 78 1 NonTreated
147 78 1 NonTreated
148 78 1 NonTreated
149 78 0 NonTreated
150 79 1 Treated
151 79 0 Treated
152 80 0 NonTreated
153 81 0 NonTreated
154 82 1 NonTreated
155 82 0 NonTreated
156 83 1 Treated
157 83 0 Treated
158 84 1 NonTreated
159 84 0 NonTreated
160 85 0 Treated
161 86 1 Treated
162 86 1 Treated
163 86 0 Treated
164 87 1 Treated
165 87 0 Treated
166 88 1 NonTreated
167 88 0 NonTreated
168 89 0 Treated
169 90 0 Treated
170 91 1 NonTreated
171 91 1 NonTreated
172 91 0 NonTreated
173 92 0 NonTreated
174 93 1 NonTreated
175 93 1 NonTreated
176 93 1 NonTreated
177 93 0 NonTreated
178 94 1 Treated
179 94 0 Treated
180 95 0 Treated
181 96 0 Treated
182 97 1 Treated
183 97 1 Treated
184 97 1 Treated
185 97 0 Treated
186 98 1 Treated
187 98 1 Treated
188 98 0 Treated
189 99 0 NonTreated
190 100 1 NonTreated
191 100 0 NonTreated
192 101 0 Treated
193 102 1 Treated
194 102 1 Treated
195 102 0 Treated
196 103 1 NonTreated
197 103 0 NonTreated
198 104 0 NonTreated
199 105 0 NonTreated
200 106 0 Treated
201 107 0 Treated
202 108 1 Treated
203 108 0 Treated
204 109 1 NonTreated
205 109 0 NonTreated
206 110 0 Treated
207 111 0 Treated
208 112 0 Treated
209 113 0 NonTreated
210 114 1 NonTreated
211 114 1 NonTreated
212 114 1 NonTreated
213 114 1 NonTreated
214 114 1 NonTreated
215 114 1 NonTreated
216 114 1 NonTreated
217 114 1 NonTreated
218 114 1 NonTreated
219 114 0 NonTreated
220 115 1 NonTreated
221 115 1 NonTreated
222 115 0 NonTreated
223 116 0 NonTreated
224 117 1 NonTreated
225 117 0 NonTreated
226 118 1 Treated
227 118 0 Treated
228 119 1 NonTreated
229 119 0 NonTreated
230 120 0 NonTreated
231 121 0 NonTreated
232 122 1 NonTreated
233 122 1 NonTreated
234 122 1 NonTreated
235 122 1 NonTreated
236 122 0 NonTreated
237 123 0 Treated
238 124 0 NonTreated
239 125 1 Treated
240 125 0 Treated
241 126 1 Treated
242 126 0 Treated
243 127 0 NonTreated
244 128 1 NonTreated
245 128 0 NonTreated
246 129 1 NonTreated
247 129 1 NonTreated
248 129 0 NonTreated
249 130 0 Treated
250 131 1 NonTreated
251 131 1 NonTreated
252 131 1 NonTreated
253 131 1 NonTreated
254 131 0 NonTreated
255 132 1 NonTreated
256 132 0 NonTreated
257 133 1 NonTreated
258 133 1 NonTreated
259 133 1 NonTreated
260 133 0 NonTreated
261 134 1 NonTreated
262 134 0 NonTreated
263 135 1 NonTreated
264 135 1 NonTreated
265 135 1 NonTreated
266 135 1 NonTreated
267 135 0 NonTreated
268 136 1 NonTreated
269 136 1 NonTreated
270 136 1 NonTreated
271 136 1 NonTreated
272 136 0 NonTreated
273 137 0 NonTreated
274 138 1 Treated
275 138 1 Treated
276 138 1 Treated
277 138 0 Treated
278 139 0 NonTreated
279 140 0 Treated
280 141 1 Treated
281 141 1 Treated
282 141 1 Treated
283 141 0 Treated
284 142 1 Treated
285 142 0 Treated
286 143 1 NonTreated
287 143 0 NonTreated
288 144 1 Treated
289 144 0 Treated
290 145 0 Treated
291 146 1 NonTreated
292 146 0 NonTreated
293 147 1 Treated
294 147 1 Treated
295 147 1 Treated
296 147 1 Treated
297 147 0 Treated
298 148 1 Treated
299 148 0 Treated
300 149 1 Treated
301 149 1 Treated
302 149 0 Treated
303 150 1 Treated
304 150 0 Treated
305 151 0 Treated
306 152 0 Treated
307 153 1 NonTreated
308 153 1 NonTreated
309 153 0 NonTreated
310 154 1 Treated
311 154 1 Treated
312 154 0 Treated
313 155 0 Treated
314 156 1 Treated
315 156 1 Treated
316 156 0 Treated
317 157 0 Treated
318 158 0 Treated
319 159 0 Treated
320 160 1 Treated
321 160 1 Treated
322 160 0 Treated
323 161 0 NonTreated
324 162 0 Treated
325 163 0 NonTreated
326 164 0 Treated
327 165 0 Treated
328 166 0 NonTreated
329 167 0 Treated
330 168 1 NonTreated
331 168 0 NonTreated
332 169 0 NonTreated
333 170 1 NonTreated
334 170 1 NonTreated
335 170 0 NonTreated
336 171 1 NonTreated
337 171 1 NonTreated
338 171 0 NonTreated
339 172 0 Treated
340 173 0 Treated
341 174 1 Treated
342 174 1 Treated
343 174 1 Treated
344 174 1 Treated
345 174 0 Treated
346 175 0 Treated
347 176 1 Treated
348 176 0 Treated
349 177 1 NonTreated
350 177 1 NonTreated
351 177 0 NonTreated
352 178 0 NonTreated
353 179 0 Treated
354 180 1 Treated
355 180 0 Treated
356 181 0 Treated
357 182 0 NonTreated
358 183 1 Treated
359 183 1 Treated
360 183 1 Treated
361 183 1 Treated
362 183 1 Treated
363 183 0 Treated
364 184 1 NonTreated
365 184 0 NonTreated
366 185 1 NonTreated
367 185 0 NonTreated
368 186 1 NonTreated
369 186 1 NonTreated
370 186 1 NonTreated
371 186 0 NonTreated
372 187 1 NonTreated
373 187 1 NonTreated
374 187 0 NonTreated
375 188 0 Treated
376 189 0 Treated
377 190 1 Treated
378 190 1 Treated
379 190 0 Treated
380 191 1 Treated
381 191 1 Treated
382 191 0 Treated
383 192 1 NonTreated
384 192 1 NonTreated
385 192 1 NonTreated
386 192 0 NonTreated
387 193 0 NonTreated
388 194 1 Treated
389 194 0 Treated
390 195 0 Treated
391 196 0 Treated
392 197 0 NonTreated
393 198 1 Treated
394 198 0 Treated
395 199 1 NonTreated
396 199 0 NonTreated
397 200 0 Treated
398 201 1 Treated
399 201 1 Treated
400 201 1 Treated
401 201 1 Treated
402 201 1 Treated
403 201 1 Treated
404 201 0 Treated
405 202 1 NonTreated
406 202 1 NonTreated
407 202 0 NonTreated
408 203 1 Treated
409 203 0 Treated
410 204 0 NonTreated
411 205 0 Treated
412 206 1 Treated
413 206 0 Treated
414 207 0 Treated
415 208 1 Treated
416 208 0 Treated
417 209 1 Treated
418 209 1 Treated
419 209 1 Treated
420 209 1 Treated
421 209 1 Treated
422 209 1 Treated
423 209 0 Treated
424 210 0 Treated
425 211 0 NonTreated
426 212 1 NonTreated
427 212 1 NonTreated
428 212 1 NonTreated
429 212 0 NonTreated
430 213 0 Treated
431 214 1 Treated
432 214 1 Treated
433 214 1 Treated
434 214 1 Treated
435 214 0 Treated
436 215 0 Treated
437 216 0 Treated
438 217 0 Treated
439 218 0 Treated
440 219 1 NonTreated
441 219 1 NonTreated
442 219 1 NonTreated
443 219 0 NonTreated
444 220 1 Treated
445 220 1 Treated
446 220 0 Treated
447 221 1 Treated
448 221 1 Treated
449 221 0 Treated
450 222 0 Treated
451 223 0 Treated
452 224 1 NonTreated
453 224 0 NonTreated
454 225 0 Treated
455 226 1 NonTreated
456 226 0 NonTreated
457 227 0 NonTreated
458 228 1 Treated
459 228 1 Treated
460 228 1 Treated
461 228 1 Treated
462 228 1 Treated
463 228 0 Treated
464 229 1 Treated
465 229 0 Treated
466 230 0 Treated
467 231 0 Treated
468 232 1 NonTreated
469 232 1 NonTreated
470 232 1 NonTreated
471 232 1 NonTreated
472 232 0 NonTreated
473 233 0 NonTreated
474 234 0 Treated
475 235 1 NonTreated
476 235 1 NonTreated
477 235 0 NonTreated
478 236 0 Treated
479 237 1 NonTreated
480 237 0 NonTreated
481 238 0 Treated
482 239 0 Treated
483 240 1 NonTreated
484 240 1 NonTreated
485 240 0 NonTreated
486 241 1 NonTreated
487 241 0 NonTreated
488 242 1 NonTreated
489 242 1 NonTreated
490 242 0 NonTreated
491 243 1 NonTreated
492 243 1 NonTreated
493 243 1 NonTreated
494 243 0 NonTreated
495 244 0 Treated
496 245 0 Treated
497 246 1 Treated
498 246 0 Treated
499 247 1 Treated
500 247 1 Treated
501 247 0 Treated
502 248 0 NonTreated
503 249 0 NonTreated
504 250 1 NonTreated
505 250 0 NonTreated
506 251 1 NonTreated
507 251 0 NonTreated
508 252 1 Treated
509 252 0 Treated
510 253 1 NonTreated
511 253 0 NonTreated
512 254 1 NonTreated
513 254 1 NonTreated
514 254 0 NonTreated
515 255 0 Treated
516 256 1 Treated
517 256 0 Treated
518 257 0 Treated
519 258 0 Treated
520 259 0 NonTreated
521 260 0 Treated
522 261 0 Treated
523 262 1 Treated
524 262 0 Treated
525 263 1 NonTreated
526 263 0 NonTreated
527 264 0 NonTreated
528 265 0 NonTreated
529 266 0 NonTreated
530 267 0 NonTreated
531 268 0 NonTreated
532 269 1 NonTreated
533 269 1 NonTreated
534 269 1 NonTreated
535 269 1 NonTreated
536 269 1 NonTreated
537 269 1 NonTreated
538 269 1 NonTreated
539 269 1 NonTreated
540 269 1 NonTreated
541 269 1 NonTreated
542 269 0 NonTreated
543 270 1 Treated
544 270 1 Treated
545 270 0 Treated
546 271 0 Treated
547 272 1 Treated
548 272 0 Treated
549 273 0 Treated
550 274 1 NonTreated
551 274 1 NonTreated
552 274 1 NonTreated
553 274 1 NonTreated
554 274 1 NonTreated
555 274 1 NonTreated
556 274 1 NonTreated
557 274 1 NonTreated
558 274 1 NonTreated
559 274 1 NonTreated
560 274 1 NonTreated
561 274 1 NonTreated
562 274 1 NonTreated
563 274 1 NonTreated
564 274 1 NonTreated
565 274 1 NonTreated
566 274 0 NonTreated
567 275 1 Treated
568 275 0 Treated
569 276 1 NonTreated
570 276 1 NonTreated
571 276 1 NonTreated
572 276 0 NonTreated
573 277 1 NonTreated
574 277 0 NonTreated
575 278 1 Treated
576 278 1 Treated
577 278 0 Treated
578 279 0 NonTreated
579 280 1 NonTreated
580 280 1 NonTreated
581 280 1 NonTreated
582 280 1 NonTreated
583 280 0 NonTreated
584 281 0 NonTreated
585 282 1 NonTreated
586 282 1 NonTreated
587 282 0 NonTreated
588 283 1 NonTreated
589 283 0 NonTreated
590 284 0 NonTreated
591 285 0 NonTreated
592 286 0 NonTreated
593 287 0 Treated
594 288 1 Treated
595 288 0 Treated
596 289 0 Treated
597 290 1 NonTreated
598 290 0 NonTreated
599 291 0 Treated
600 292 1 NonTreated
601 292 0 NonTreated
602 293 0 NonTreated
603 294 0 Treated
604 295 0 Treated
605 296 1 Treated
606 296 0 Treated
607 297 0 NonTreated
608 298 1 NonTreated
609 298 1 NonTreated
610 298 1 NonTreated
611 298 1 NonTreated
612 298 1 NonTreated
613 298 0 NonTreated
614 299 0 NonTreated
615 300 1 Treated
616 300 0 Treated
617 301 1 NonTreated
618 301 1 NonTreated
619 301 1 NonTreated
620 301 0 NonTreated
621 302 1 Treated
622 302 1 Treated
623 302 0 Treated
624 303 0 Treated
625 304 1 NonTreated
626 304 1 NonTreated
627 304 1 NonTreated
628 304 1 NonTreated
629 304 0 NonTreated
630 305 1 NonTreated
631 305 0 NonTreated
632 306 0 Treated
633 307 1 Treated
634 307 0 Treated
635 308 0 NonTreated
636 309 1 NonTreated
637 309 1 NonTreated
638 309 1 NonTreated
639 309 0 NonTreated
640 310 1 NonTreated
641 310 0 NonTreated
642 311 0 Treated
643 312 0 NonTreated
644 313 0 NonTreated
645 314 0 Treated
646 315 1 Treated
647 315 0 Treated
648 316 1 Treated
649 316 0 Treated
650 317 1 NonTreated
651 317 1 NonTreated
652 317 1 NonTreated
653 317 1 NonTreated
654 317 1 NonTreated
655 317 1 NonTreated
656 317 1 NonTreated
657 317 1 NonTreated
658 317 0 NonTreated
659 318 1 Treated
660 318 1 Treated
661 318 1 Treated
662 318 1 Treated
663 318 1 Treated
664 318 1 Treated
665 318 0 Treated
666 319 0 Treated
667 320 1 NonTreated
668 320 0 NonTreated
669 321 1 Treated
670 321 1 Treated
671 321 0 Treated
672 322 1 Treated
673 322 0 Treated
674 323 0 NonTreated
675 324 1 Treated
676 324 0 Treated
677 325 1 NonTreated
678 325 1 NonTreated
679 325 1 NonTreated
680 325 0 NonTreated
681 326 0 Treated
682 327 1 NonTreated
683 327 1 NonTreated
684 327 1 NonTreated
685 327 1 NonTreated
686 327 0 NonTreated
687 328 0 NonTreated
688 329 0 Treated
689 330 0 NonTreated
690 331 1 Treated
691 331 0 Treated
692 332 0 Treated
693 333 0 Treated
694 334 1 NonTreated
695 334 0 NonTreated
696 335 1 NonTreated
697 335 0 NonTreated
698 336 1 NonTreated
699 336 1 NonTreated
700 336 1 NonTreated
701 336 1 NonTreated
702 336 1 NonTreated
703 336 0 NonTreated
704 337 0 NonTreated
705 338 0 Treated
706 339 1 NonTreated
707 339 1 NonTreated
708 339 0 NonTreated
709 340 0 NonTreated
710 341 0 Treated
711 342 0 NonTreated
712 343 0 NonTreated
713 344 0 Treated
714 345 0 Treated
715 346 0 Treated
716 347 1 NonTreated
717 347 1 NonTreated
718 347 1 NonTreated
719 347 0 NonTreated
720 348 1 NonTreated
721 348 1 NonTreated
722 348 1 NonTreated
723 348 1 NonTreated
724 348 0 NonTreated
725 349 1 NonTreated
726 349 0 NonTreated
727 350 1 NonTreated
728 350 1 NonTreated
729 350 1 NonTreated
730 350 1 NonTreated
731 350 1 NonTreated
732 350 1 NonTreated
733 350 1 NonTreated
734 350 1 NonTreated
735 350 1 NonTreated
736 350 1 NonTreated
737 350 1 NonTreated
738 350 1 NonTreated
739 350 1 NonTreated
740 350 1 NonTreated
741 350 1 NonTreated
742 350 1 NonTreated
743 350 1 NonTreated
744 350 1 NonTreated
745 350 1 NonTreated
746 350 1 NonTreated
747 350 1 NonTreated
748 350 1 NonTreated
749 350 0 NonTreated
750 351 1 NonTreated
751 351 1 NonTreated
752 351 1 NonTreated
753 351 0 NonTreated
754 352 0 NonTreated
755 353 1 NonTreated
756 353 0 NonTreated
757 354 1 NonTreated
758 354 0 NonTreated
759 355 1 Treated
760 355 0 Treated
761 356 0 NonTreated
762 357 1 NonTreated
763 357 0 NonTreated
764 358 0 NonTreated
765 359 0 Treated
766 360 0 Treated
767 361 1 NonTreated
768 361 0 NonTreated
769 362 0 Treated
770 363 0 Treated
771 364 0 Treated
772 365 0 NonTreated
773 366 1 Treated
774 366 0 Treated
775 367 0 Treated
776 368 1 NonTreated
777 368 1 NonTreated
778 368 0 NonTreated
779 369 1 NonTreated
780 369 0 NonTreated
781 370 1 NonTreated
782 370 1 NonTreated
783 370 0 NonTreated
784 371 0 Treated
785 372 0 NonTreated
786 373 0 Treated
787 374 0 Treated
788 375 0 Treated
789 376 0 NonTreated
790 377 0 Treated
791 378 1 NonTreated
792 378 1 NonTreated
793 378 0 NonTreated
794 379 1 Treated
795 379 1 Treated
796 379 1 Treated
797 379 1 Treated
798 379 1 Treated
799 379 0 Treated
800 380 0 NonTreated
801 381 0 Treated
802 382 0 NonTreated
803 383 1 Treated
804 383 0 Treated
805 384 0 Treated
806 385 0 Treated
807 386 0 Treated
808 387 0 NonTreated
809 388 0 NonTreated
810 389 1 Treated
811 389 1 Treated
812 389 1 Treated
813 389 0 Treated
814 390 0 NonTreated
815 391 0 Treated
816 392 1 NonTreated
817 392 0 NonTreated
818 393 1 NonTreated
819 393 1 NonTreated
820 393 1 NonTreated
821 393 1 NonTreated
822 393 1 NonTreated
823 393 0 NonTreated
824 394 1 Treated
825 394 0 Treated
826 395 1 Treated
827 395 0 Treated
828 396 1 Treated
829 396 1 Treated
830 396 1 Treated
831 396 1 Treated
832 396 1 Treated
833 396 0 Treated
834 397 1 NonTreated
835 397 1 NonTreated
836 397 1 NonTreated
837 397 0 NonTreated
838 398 1 Treated
839 398 0 Treated
840 399 1 NonTreated
841 399 1 NonTreated
842 399 1 NonTreated
843 399 1 NonTreated
844 399 1 NonTreated
845 399 1 NonTreated
846 399 1 NonTreated
847 399 1 NonTreated
848 399 1 NonTreated
849 399 1 NonTreated
850 399 1 NonTreated
851 399 0 NonTreated
852 400 0 Treated
853 401 1 NonTreated
854 401 1 NonTreated
855 401 1 NonTreated
856 401 1 NonTreated
857 401 1 NonTreated
858 401 0 NonTreated
859 402 1 NonTreated
860 402 0 NonTreated
861 403 0 Treated
答案 0 :(得分:2)
您的问题不在您提供的代码中,而是在它之前。您没有成功创建readm
。为了表明这一点,请运行以下代码:
proc print data=readm (obs=9);
run;
(obs=
只是将列表限制为9个观察值。)
不知何故,SAS必须通知您的第四栏是文本栏
你可能写过像
这样的东西data readm;
infile 'C:\<some path>\<some file>';
input Oss id event chemo;
run;
我会将其视为
data readm;
infile 'C:\<some path>\<some file>' truncover dsd dlm='09'x;
input Oss id event chemo $9.;
run;
在此
dcd
指定您有分隔符dlm='09'x
指定您的分隔符是标签truncover
指定您不想阅读下一行以查找“化疗”的最后一个字符。下一行的字段如果这不是您问题的答案,请告诉我们您如何创建/导入readm
,我们会看到我们可以做些什么。
免责声明:此代码未经过测试。如果它有错误,请通知我,我会调试它。