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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
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!

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20
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!

smart
Fluorite | Level 6

Thank you! This worked!

novinosrin
Tourmaline | Level 20
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
;

 

Haikuo
Onyx | Level 15

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
;

 

 

Astounding
PROC Star

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;

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 2813 views
  • 1 like
  • 4 in conversation