DATA Step, Macro, Functions and more

Create a dataset with date information

Accepted Solution Solved
Reply
Regular Contributor
Posts: 154
Accepted Solution

Create a dataset with date information

Hi,

 

How could I create a dataset with three columns like below:

 

LOC_ID |  Date | Demand

.....         |  ....    | ....

 

Where demand is always 0 and Date is from 01JAN2017 to 30JUN2017 and LOC_ID is always C1.

 

Thank you!


Accepted Solutions
Solution
‎01-30-2017 09:12 AM
Esteemed Advisor
Posts: 5,482

Re: Create a dataset with date information

data want;
length LOC_ID $8 Date Demand 8;
LOC_ID = "C1";
demand = 0;
do Date = '01JAN2017'd to '30JUN2017'd;
	output;
	end;
run;
PG

View solution in original post


All Replies
Solution
‎01-30-2017 09:12 AM
Esteemed Advisor
Posts: 5,482

Re: Create a dataset with date information

data want;
length LOC_ID $8 Date Demand 8;
LOC_ID = "C1";
demand = 0;
do Date = '01JAN2017'd to '30JUN2017'd;
	output;
	end;
run;
PG
Super User
Posts: 9,901

Re: Create a dataset with date information

The only thing I'd add would be

format date date9.;

for better readability. Smiley Wink

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 692 views
  • 3 likes
  • 3 in conversation