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

Hello Beautiful People!

 

I have a simple SAS program that's producing blanks when I run it.  The program is below (my intention is for the program to produce what the datalines statement shows):

 

data work.example_2012;
infile datalines dsd;
	input
	Month monyy6.
	Sales: dollars.;
	format month monyy. Sales dollars4.2;
;
datalines;
12-Jan $1,000.00 
12-Feb $2,000.00 
12-Mar $3,000.00 
12-Apr $4,000.00
12-May $5,000.00 
12-Jun $6,000.00
12-Jul $7,000.00
12-Aug $8,000.00 
12-Sep $9,000.00 
12-Oct $10,000.00
12-Nov $11,000.00 
12-Dec $12,000.00 
;
run;

And the output is like so:

 

Month Sales
.	.   
.	.  
.	.  
.	.  
.	.  
.	.  
.	.  
.	.  
.	.  
.	.  
.	.  
.	.  

Can someone tell me what I'm doing wrong?  Any guidance is greatly appreciated!

 

-Valentine

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

HI @davidvalentine  If you are not really picky, plz read as char and not bother with informat and format

 

data work.example_2012;
infile datalines ;
	input
	month $
	Sales: dollar10.;
	format  Sales dollar10.2;
;
datalines;
12-Jan $1,000.00 
12-Feb $2,000.00 
12-Mar $3,000.00 
12-Apr $4,000.00
12-May $5,000.00 
12-Jun $6,000.00
12-Jul $7,000.00
12-Aug $8,000.00 
12-Sep $9,000.00 
12-Oct $10,000.00
12-Nov $11,000.00 
12-Dec $12,000.00 
;
run;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

What date do your want 12-feb to resolve to? 12 feb 2020? 2019?

davidvalentine
Obsidian | Level 7

Hi draycut,

 

I'd like the date to come out to the following format: "12-Jan" although I'm not picky about it as much as I need the Sales to be $xxxx.xx

novinosrin
Tourmaline | Level 20

HI @davidvalentine  If you are not really picky, plz read as char and not bother with informat and format

 

data work.example_2012;
infile datalines ;
	input
	month $
	Sales: dollar10.;
	format  Sales dollar10.2;
;
datalines;
12-Jan $1,000.00 
12-Feb $2,000.00 
12-Mar $3,000.00 
12-Apr $4,000.00
12-May $5,000.00 
12-Jun $6,000.00
12-Jul $7,000.00
12-Aug $8,000.00 
12-Sep $9,000.00 
12-Oct $10,000.00
12-Nov $11,000.00 
12-Dec $12,000.00 
;
run;
davidvalentine
Obsidian | Level 7
Perfect; this gets the job done. Thank you!!!

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 733 views
  • 1 like
  • 3 in conversation