BookmarkSubscribeRSS Feed
Batman
Quartz | Level 8

I'm trying to create a dataset from some columns I copied from a text file.  Ideally, I'd like the roman numerals to appear in the first column and the numbers with the decimals in the second column, both as text variables.   However, SAS isn't recognizing the space that separates the two columns.   See what the put statement yields below.

 

data Sel;

input rom $ num $;

datalines;

 

i. 290.0

ii. 290.1

;

run;

 

data null;

set sel;

put rom= num=;

run;

 

The put statement yield the following in the log.

 

rom=i. 290.0 num=ii. 290.

1 REPLY 1
ballardw
Super User

Blank lines in a datalines block are seldom a good idea.

This seems to work for me but it is possible that between pasting to the forum message window, my copy and paste into the editor and running the code removed a problem character.

data Sel;
input rom $ num $;
datalines;
i. 290.0
ii. 290.1
;
run;

I suggest going back to your editor, copying the code and then pasting into a code box opened using the forum {I} icon so you are pasting in a plain text box.

 

I suspect that you may have copied data from a TAB delimited file which would look like spaces but aren't. That could be tested by adding an infile statement to us tabs:

data Sel;
infile datalines dlm='09'x;
input rom $ num $;

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 530 views
  • 0 likes
  • 2 in conversation