BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
u39734216
Fluorite | Level 6

Hi all,

I have data set which has delimiter values like this 1Sep11 389.00 1Oct11 491.00 1Nov11 370.00 1Dec11 335.00

and I want to get these values in two columns like Date and sales amount. I was this code. pls, can anyone tell me what I'm doing wrong? 

 


data Daily_sales;
infile 'D:\SASUniversityEdition\Daily_sales.txt';
input Date Sales_Amount  @@;
format date Sales_Amount ;
run;



1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data Daily_sales;
infile 'D:\SASUniversityEdition\Daily_sales.txt';
input Date :DATE7. Sales_Amount  @@;
format date DATE9. Sales_Amount ;
run;

View solution in original post

6 REPLIES 6
novinosrin
Tourmaline | Level 20
data Daily_sales;
infile 'D:\SASUniversityEdition\Daily_sales.txt';
input Date :DATE7. Sales_Amount  @@;
format date DATE9. Sales_Amount ;
run;
PeterClemmensen
Tourmaline | Level 20

Please describe what the problem is? How does your result differ from the result you want to see?

u39734216
Fluorite | Level 6
It is not giving me the sales amount in a proper way. Like 389.00

It's showing me 389 only.
novinosrin
Tourmaline | Level 20

hello @u39734216  If format is your concern, try this format

 

format date DATE9. Sales_Amount 8.2 ;
ballardw
Super User

@u39734216 wrote:
It is not giving me the sales amount in a proper way. Like 389.00

It's showing me 389 only.

If you do not assign a specific display format then SAS will use one of the BEST formats, often BEST12. One behavior of the BEST formats is that if there is no non-zero decimal portion they are not displayed.

Understanding what Formats and Informats do is a key part of the flexibility of SAS.

Consider the following program code. If you submit it and examine the log you will see several different, by no means all, formats applied to the same value.

data junk;
   x=389.00;
   put "Fixed 8.2 " x= f8.2 "dollar 8.2 " x= dollar8.2
       "Leading zero " x= z8.2  "word  " x= wordf30.;

run;
Reeza
Super User

I'm 80% certain you're going to have errors throughout your log, since you're path includes SAS University Edition.

 

For starters the file path is likely incorrect if you're actually using SAS University edition so that will give you a file not found error.

Fix the file path first and then you can figure out if the rest of your code works or doesn't.

 

The filepath should likely be:

 

infile '/folders/myfolders/Daily_sales.txt';

SAS University Edition runs on a Unix system so you need Unix file paths, not Windows and unless you've set up your own shared folders you need to place your files in the myfolders folder you set up during installation.

 

 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 6 replies
  • 844 views
  • 2 likes
  • 5 in conversation