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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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