SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

combining data

Accepted Solution Solved
Reply
Occasional Contributor VS
Occasional Contributor
Posts: 15
Accepted Solution

combining data

Hi, we recieve monthly data and create YTD data. Before i just had a code  e.g. "DATA YTDdat; SET dJan dFeb ... dDec;RUN;". If there was no month mentioned in a SET statement, it would give me an error message, but will append all existing months all the same. Now I am creating essentially the same code, but it gives an error message e.g. "ERROR: File ONL_DEC15.DATA does not exist" but does not create a file with existing months. My question: is there a way to create YTD data automatically, depending on whether the data for a particular month exists?

 


Accepted Solutions
Solution
‎12-14-2015 05:13 PM
Frequent Contributor
Posts: 108

Re: combining data

 

 

Here You go ...

data jan;
input X;
datalines;
1
1
;
data Feb;
input X;
datalines;
2
2
;
OPTIONS  NODSNFERR;
data want;
set jan HELLOOOO Feb;
/* "HELLOOOO" data dont exists */
run;

 

 

View solution in original post


All Replies
Solution
‎12-14-2015 05:13 PM
Frequent Contributor
Posts: 108

Re: combining data

 

 

Here You go ...

data jan;
input X;
datalines;
1
1
;
data Feb;
input X;
datalines;
2
2
;
OPTIONS  NODSNFERR;
data want;
set jan HELLOOOO Feb;
/* "HELLOOOO" data dont exists */
run;

 

 

Occasional Contributor VS
Occasional Contributor
Posts: 15

Re: combining data

Posted in reply to pearsoninst
Thanks a lot! Have to learn more about OPTIONS.
Super User
Super User
Posts: 7,955

Re: combining data

As with anything else, I would not recommend putting "data" in the table name or table headers.  Consider your approach, what happens if you get updates for a month, what happens the next year etc.  Would it not be far easier to work with one large dataset which has another column:
DATE_RECIEVED   Other variables...

 

Then each upload, you insert the new data with a given date.  Then your programs can be written to just point to one dataset, and use the date variable to group.  Far easier than messing around with filenames etc.

Occasional Contributor VS
Occasional Contributor
Posts: 15

Re: combining data

Thank you. This is very valuable suggestion. i've got several projects which will benefit from this approach.

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 340 views
  • 0 likes
  • 3 in conversation