Hello. Below is my code. I do not have errors. However, I am having trouble with my output. How do I make all the deer names in one column and the gift in the other column? Also, how do I not display commas in my output statement? Thank you.
Data RudolphXmasList;
input DeerName $ Gift $ @@;
output;
datalines;
Dasher, hay bale, Dancer, stocking cap, Prancer, candy canes,
Vixen, red dress, Comet, astrology book, Cupid, bow and arrows,
Donner, lump of coal, Blitzen, snow shoes
;
proc print data = RudolphXmasList;
run;
Data RudolphXmasList;
infile cards dsd truncover ;
input DeerName : $15. Gift : $15. @;
do while (not missing(deername));
output;
input DeerName : $15. Gift : $15. @;
end;
datalines;
Dasher, hay bale, Dancer, stocking cap, Prancer, candy canes,
Vixen, red dress, Comet, astrology book, Cupid, bow and arrows,
Donner, lump of coal, Blitzen, snow shoes
;
Hi @smart If the above doesn't help, wait for better robust answers . Thanks!
Data RudolphXmasList;
infile cards dsd truncover ;
input DeerName : $15. Gift : $15. @;
do while (not missing(deername));
output;
input DeerName : $15. Gift : $15. @;
end;
datalines;
Dasher, hay bale, Dancer, stocking cap, Prancer, candy canes,
Vixen, red dress, Comet, astrology book, Cupid, bow and arrows,
Donner, lump of coal, Blitzen, snow shoes
;
Hi @smart If the above doesn't help, wait for better robust answers . Thanks!
Thank you! This worked!
Dasher, hay bale, Dancer, stocking cap, Prancer, candy canes, /*if you remove these comma at the right end, your code will work*/
Vixen, red dress, Comet, astrology book, Cupid, bow and arrows, /*if you remove these comma at the right end, your idea will work with some adjustments*/
Donner, lump of coal, Blitzen, snow shoes
Data RudolphXmasList;
infile cards dsd ;
input DeerName : $15. Gift : $15. @@;
datalines;
Dasher, hay bale, Dancer, stocking cap, Prancer, candy canes
Vixen, red dress, Comet, astrology book, Cupid, bow and arrows
Donner, lump of coal, Blitzen, snow shoes
;
You need to address multiple delimiters to address the misread, in your case it is comma + whatever invisible except blank (line feed, carriage return or tab?), this can't be illustrated by using in-stream data feed, as the normal behavior of 'input' statement changes.
filename FT15f001 temp;
Data RudolphXmasList;
dlm=','||'0D'x||'0A'x||'09'x;
infile FT15F001 dlm=dlm;
input DeerName :$20. Gift :$20. @@;
parmcards;
Dasher, hay bale, Dancer, stocking cap, Prancer, candy canes,
Vixen, red dress, Comet, astrology book, Cupid, bow and arrows,
Donner, lump of coal, Blitzen, snow shoes
;
I'm not sure if this is simpler or not, but it should work:
data RudolphXmasList;
infile cards dsd;
length DeerName Gift $ 15;
input DeerName Gift @@ ;
DeerName = left(DeerName);
Gift = left(Gift);
output;
datalines;
Dasher, hay bale, Dancer, stocking cap, Prancer, candy canes,
Vixen, red dress, Comet, astrology book, Cupid, bow and arrows,
Donner, lump of coal, Blitzen, snow shoes
;
proc print data = RudolphXmasList;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.