BookmarkSubscribeRSS Feed
Younes10
Calcite | Level 5

Hey guys, I'm stuck in a project. My code will only print 3 obs but I need it to print 5 as you can see the other two obs are aligned horizontally from the first and second lines of data. How do I make them print with the other 3 data lines without touching the data itself?

Screen Shot 2022-02-25 at 11.50.39 PM.png

 

This is what it prints. 

 

Screen Shot 2022-02-25 at 11.51.37 PM.png

 

But I need it to print like this. Can someone please help me?

 

Screen Shot 2022-02-25 at 11.53.55 PM.png


THANKS!

 

 

5 REPLIES 5
SASKiwi
PROC Star

Split your DATALINES rows into 5 lines, after your date variable,  then it will import and print correctly.

Younes10
Calcite | Level 5
I cannot touch the datalines. My professor said I have to write a code for it.
Patrick
Opal | Level 21

Lookup in the SAS Documentation for the INPUT statement what the @ can get used for.
Then adopt below sample to your code and data.

data test;
  infile datalines dlm=',';
  input a b @@;
  datalines;
1,2
1,2,3,4,5,6
1,2,3,4
;

proc print data=test;
run;

Patrick_0-1645859290479.png

 

Younes10
Calcite | Level 5
Thank you so much! it helped!
Tom
Super User Tom
Super User

There is no alignment required here.  Just read the values.

If you want SAS to keep reading from the same line to get the next observation then use double trailing @ on the INPUT statement.

Also read the numbers as numbers, not strings.  

And add formats to display the numbers the way you want.  Avoid MDY or DMY ordering for dates as either choice will confuse half of your audience.  Use YMD order or DATE format.

  input price :comma. sqft tax date :anydtdte. @@;
  format price dollar10.2 date yymmdd10.;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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