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;
data Daily_sales;
infile 'D:\SASUniversityEdition\Daily_sales.txt';
input Date :DATE7. Sales_Amount @@;
format date DATE9. Sales_Amount ;
run;
data Daily_sales;
infile 'D:\SASUniversityEdition\Daily_sales.txt';
input Date :DATE7. Sales_Amount @@;
format date DATE9. Sales_Amount ;
run;
Please describe what the problem is? How does your result differ from the result you want to see?
@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;
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.
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!
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.