BookmarkSubscribeRSS Feed
ldd15
Calcite | Level 5

I have been trying to copypaste data into SAS, but for whatever reason, it refuses to give me an actual set of results and just gives me empty cells in the output data tab. My professor does the same thing, but his data seems to work. I suspect that it's somehow due to the uneven nature of how my data appears in the program itself, but I'm not certain. Would anyone be willing to help clear this up?

4 REPLIES 4
Tom
Super User Tom
Super User

Copy and paste WHAT to WHERE?

 

I suspect that  if you highlight a few cells from Excel copy them and then paste them into the SAS program editor it might work to get the values there.  But depending on your setup it might paste TAB characters into the file.  (TAB characters in programs just cause a mess.) Or your SAS editor might automatically convert them into spaces, mine does.  So if the values in the cells don't have embedded spaces that works great.

data want;
  input (x1-x3) (:comma32.);
cards;
0.00%	5.00%	7.00%
92.79%	97.68%	99.78%
96.40%	98.84%	99.89%
;

Result

Obs      x1       x2       x3

 1      0.00     5.00     7.00
 2     92.79    97.68    99.78
 3     96.40    98.84    99.89

 

Show what you tried. Did you get error messages in the LOG?

ldd15
Calcite | Level 5

Dear Tom,

Forgive me for neglecting to properly describe what I was trying to do. I have since collated my problem in this word document.

 

Tom
Super User Tom
Super User

What did the SAS log show when you ran that second data step? Did it complain about invalid values?  Did it read past the end of the lines?  How many lines where read? How many observations created?

 

Copy the text from the SAS log and post it as TEXT, not attachments.  Use the Insert Code button so the forum doesn't try to reflow the lines into paragraphs.

 

Tom
Super User Tom
Super User

Do the datalines in the photograph of the second data step have tab characters in them?

If you want SAS to replace the TAB characters that might have mistakenly made their way into your program you can just add an INFILE statement before the INPUT statement so that you can add the EXPANDTABS option.

input datalines expandtabs;

That was SAS will replace any tab characters in the data lines with the number of spaces needed to advance to the next tab stop.  Tab stops are every 8 characters.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 780 views
  • 0 likes
  • 2 in conversation