Hi, I'm attaching my code. I'm not sure what else to add, but the last date 8/2/20 will not print out as a number in my results.
/* Use list style of input read in the above data such that the
dates are stored as numbers(SAS dates). Print
the resulting data set without formatting it*/
Data Power;
Length Brand $5 ;
Input Brand $
Install :DATE9.
Replace :MMDDYY8. ; /*dates are stored as numbers*/
/*list style of input but do not format*/
datalines;
Zap 13MAR2019 12/20/19
Jolt 29FEB2020 9/29/20
Shock 25MAR2020 8/2/20
;
run;
proc print data=Power;
run;
This is my results:
Brand Install Replace
Zap | 21621 | 21903 |
Jolt | 21974 | 22187 |
Shock | 21999 | . |
How do I get observation 3 under replace to print?
Thank you
Oh, and the reason I say "interesting" is because when I paste your code into Enterprise Guide, it runs just fine. Are you using SAS Studio (Univ Edition is one form of SAS Studio)?
Make sure your datalines are all hard up against the left margin.
For any future posts of code or log files, please use the buttons on the reply window. It really makes it easier for us to see what's going on.
Jim
Interesting.
I would try informat ANYDTDTE10. instead of MMDDYY8., but I'm not sure that's it.
I would next try coding an INFILE and trying first a MISSOVER and second a TRUNCOVER parameter on the INFILE.
Jim
Oh, and the reason I say "interesting" is because when I paste your code into Enterprise Guide, it runs just fine. Are you using SAS Studio (Univ Edition is one form of SAS Studio)?
Make sure your datalines are all hard up against the left margin.
For any future posts of code or log files, please use the buttons on the reply window. It really makes it easier for us to see what's going on.
Jim
I have a secret way of knowing these things (I've done it too). 🙂 Glad it worked out.
Jim
The code you posted, at least as shown, runs and gets a valid date for me for the 8/2/20 value.
If you are actually reading from an external file and having this issue then copy the lines from that file and paste into a code box opened on the forum using the </> icon to preserve formatting.
Or check your source code for other characters that the message window on the forum may have reformatted so that the code shown is not what you actually have.
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 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: