DATA Step, Macro, Functions and more

Create a dataset with date information

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 107
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
Respected Advisor
Posts: 4,646

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
Respected Advisor
Posts: 4,646

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: 6,936

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
☑ This topic is SOLVED.

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

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