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

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

Zap2162121903
Jolt2197422187
Shock21999.

 

How do I get observation 3 under replace to print?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
jimbarbour
Meteorite | Level 14

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)?

jimbarbour_0-1602603797479.png

 

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.

 

jimbarbour_0-1602603718187.png

 

Jim

View solution in original post

5 REPLIES 5
jimbarbour
Meteorite | Level 14

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

jimbarbour
Meteorite | Level 14

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)?

jimbarbour_0-1602603797479.png

 

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.

 

jimbarbour_0-1602603718187.png

 

Jim

sb1062204
Calcite | Level 5
The spacing in the datalines was off, thank you so much for your help
jimbarbour
Meteorite | Level 14

I have a secret way of knowing these things (I've done it too).  🙂  Glad it worked out.  

 

Jim

ballardw
Super User

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.

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

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
  • 993 views
  • 1 like
  • 3 in conversation