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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1359 views
  • 1 like
  • 4 in conversation