BookmarkSubscribeRSS Feed
Siddharth123
Obsidian | Level 7

Hi All,

I am using the code:


DATA test;
INPUT   X : 2
            Y : 1.
            A & $11.
            Z : 1.;
DATALINES;
1 2 HELLO WORLD 3
4 5 S BEHNOI 6
;
PROC PRINT DATA=Test;
RUN;

This doesnt read the file correctly. I do not want to change the order of my datalines, could you suggest what change I shoukd make in the Input lines so as to read the data correctly.

Kind Regards

Siddharth

1 REPLY 1
Tom
Super User Tom
Super User

I think your question is how can you read the variable length string in the middle of the line that might had embedded blanks and does NOT have two spaces after it to indicate the end of the variable length string.

In general you cannot.  So you will have to use some other method to determining where the number at the end of the line starts.

DATA test;

  INPUT  x y a & $14. ;

  j=input(scan(a,-1,' '),2.);

  a=substr(a,1,length(a) - length(scan(a,-1,' ')));

  put / _infile_ / (_all_) (=);

DATALINES;               

1 2 HELLO WORLD 3              

4 5 S BEHNOI 6  

;


1 2 HELLO WORLD 3

x=1 y=2 a=HELLO WORLD j=3

4 5 S BEHNOI 6

x=4 y=5 a=S BEHNOI j=6


sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 638 views
  • 4 likes
  • 2 in conversation