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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.