Actuarial Outpost
 
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Software & Technology
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions


Upload your resume securely at https://www.dwsimpson.com
to be contacted when new jobs meet your skills and objectives.


Reply
 
Thread Tools Display Modes
  #31  
Old 02-09-2011, 11:47 AM
ThatGuy's Avatar
ThatGuy ThatGuy is offline
Member
 
Join Date: Aug 2010
College: I'm Old.
Posts: 1,202
Default

okay I will work on the macro step....Can you explain the %mend? I'll give you an update after I fill in some things and screw it up...
Reply With Quote
  #32  
Old 02-09-2011, 12:03 PM
ThatGuy's Avatar
ThatGuy ThatGuy is offline
Member
 
Join Date: Aug 2010
College: I'm Old.
Posts: 1,202
Default

Okay I almost got the loop working, but for the numbers:

I am using, and when I refer to the month I need it to be in the format 01, how do I ensure this?

%do mth = 01 %to 12;
Reply With Quote
  #33  
Old 02-09-2011, 12:22 PM
dumples dumples is offline
Member
CAS
 
Join Date: Sep 2003
Posts: 1,229
Default

This is a little hard to explain when to use one thing and not another, but here a two code snippets that should be helpful.

PUT(&i,z2.)
%SYSFUNC
(PUTN(&i,z2.))

I'll post more later, I just have some more work to do right now.
Reply With Quote
  #34  
Old 02-09-2011, 12:40 PM
ThatGuy's Avatar
ThatGuy ThatGuy is offline
Member
 
Join Date: Aug 2010
College: I'm Old.
Posts: 1,202
Default

modified using If mth <10
%let subdirectory with 0 before mth
else
subdirectory without 0...

easy fix...(sorry this prolly makes little sense)
Reply With Quote
  #35  
Old 02-09-2011, 12:43 PM
ThatGuy's Avatar
ThatGuy ThatGuy is offline
Member
 
Join Date: Aug 2010
College: I'm Old.
Posts: 1,202
Default

Good to hear all the different ways to do the same thing!
Reply With Quote
  #36  
Old 02-09-2011, 01:33 PM
dumples dumples is offline
Member
CAS
 
Join Date: Sep 2003
Posts: 1,229
Default

Ok, so the setup here is that I have a library called dLib which is my main folder. In that folder, I have two other folders f1101 and f1102 and I want to create libname statements for those 2 directories

essentially i want to write
Spoiler:

Code:
 
libname f1101 '/sas/sasusers/dumples/f1101';
libname f1102 '/sas/sasusers/dumples/f1102';


Spoiler:

Code:
 
libname dLib '/sas/sasusers/dumples/';run;
%Let rootFolder = /sas/sasusers/dumples/;
%Let valdate = %sysfunc(MDY(1,1,2011));
%Macro Declarelibs(dl_Start=,dl_Stop=);
%IF &dl_START LE &dl_Stop %THEN%DO;
%Do dl_i = &dl_Start %to &dl_Stop;
DATA _null_;
valdate2 = intnx("month",&valdate, &dl_i);
LENGTH valYYMM $4.;
valYYMM = substr(PUT(year(valdate2),z4.),3,2)||PUT(month(valdate2),z2.);
call symput('valYYMM',valYYMM);
RUN;
libname f&valyymm.lib %Sysfunc(QUOTE(&Rootfolder.f&valyymm.));
%END; *End of Loop;
%END; *End of IF statement;
%Mend DeclareLibs;
%Declarelibs(dl_start = 0, dl_stop = 1);run;
Reply With Quote
  #37  
Old 02-09-2011, 01:37 PM
dumples dumples is offline
Member
CAS
 
Join Date: Sep 2003
Posts: 1,229
Default

So that prior thing should've just created the library references, now you need to append your tables. Here's what you need to do to append your tables together. I haven't finished this, the stuff that is hard coded in red needs to be changed to a formula.

Spoiler:

Code:
 
%MACRO AppendFiles(af_outLib=,af_OutFile=, inFile=, af_Start=, af_Stop=); 
%IF &af_START LE &af_Stop %THEN %DO;
DATA &af_outLib..&af_outFile.; 
SET 
%DO af_i = &af_Start %to &af_Stop; 
f%SYSFUNC(PUTN(1101,z4.))lib.&infile.
%END; 
; /* this additional ';' is necessary, the first ';' is for the '%END', while the second ';' is for 'SET' */
RUN; 
%END; *End of IF statement;
%MEND AppendFiles;
%AppendFiles(af_outLib= work,af_OutFile= test, inFile=test , af_Start=0, af_Stop=1);
Reply With Quote
  #38  
Old 02-09-2011, 01:42 PM
dumples dumples is offline
Member
CAS
 
Join Date: Sep 2003
Posts: 1,229
Default

I can't get the formatting correct on the AO, here's a screen shot.

Hope this helps.
Attached Images
 
Reply With Quote
  #39  
Old 02-09-2011, 01:59 PM
BassFreq's Avatar
BassFreq BassFreq is offline
Member
CAS
 
Join Date: Jun 2003
Location: Chicago
Studying for all eternity
Favorite beer: Duff
Posts: 1,668
Blog Entries: 2
Default

I think you just want
f%SYSFUNC(PUTN(&af_i,z4.))lib.&infile.
__________________
If at first you don't succeed, you have one data point.
Res ipsa loquitur, sed quid in infernos dicet?
Reply With Quote
  #40  
Old 02-09-2011, 02:03 PM
ThatGuy's Avatar
ThatGuy ThatGuy is offline
Member
 
Join Date: Aug 2010
College: I'm Old.
Posts: 1,202
Default

Possibly I will improve my rag tag coding in the future with your elite efforts.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 09:35 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.25182 seconds with 10 queries