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

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
pearsoninst
Pyrite | Level 9

 

 

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

4 REPLIES 4
pearsoninst
Pyrite | Level 9

 

 

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;

 

 

VS
Calcite | Level 5 VS
Calcite | Level 5
Thanks a lot! Have to learn more about OPTIONS.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

VS
Calcite | Level 5 VS
Calcite | Level 5

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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

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