Actuarial Outpost Simple SAS Questions
 User Name Remember Me? Password
 Register Blogs Wiki FAQ Calendar Search Today's Posts Mark Forums Read
 FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions

 Enter your email to subscribe to DW Simpson weekly actuarial job updates. li.signup { display: block; text-align: center; text-size: .8; padding: 0px; margin: 8px; float: left; } Entry Level Casualty Health Life Pension All Jobs

 Thread Tools Search this Thread Display Modes
#31
02-09-2011, 11:47 AM
 ThatGuy Member Join Date: Aug 2010 College: I'm Old. Posts: 1,202

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...
#32
02-09-2011, 12:03 PM
 ThatGuy Member Join Date: Aug 2010 College: I'm Old. Posts: 1,202

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;
#33
02-09-2011, 12:22 PM
 dumples Member CAS Join Date: Sep 2003 Posts: 1,246

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.
#34
02-09-2011, 12:40 PM
 ThatGuy Member Join Date: Aug 2010 College: I'm Old. Posts: 1,202

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

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

Good to hear all the different ways to do the same thing!
#36
02-09-2011, 01:33 PM
 dumples Member CAS Join Date: Sep 2003 Posts: 1,246

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;
```
#37
02-09-2011, 01:37 PM
 dumples Member CAS Join Date: Sep 2003 Posts: 1,246

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);```
#38
02-09-2011, 01:42 PM
 dumples Member CAS Join Date: Sep 2003 Posts: 1,246

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

Hope this helps.
Attached Images

#39
02-09-2011, 01:59 PM
 BassFreq Member CAS Join Date: Jun 2003 Location: Chicago Studying for all eternity Favorite beer: Duff Posts: 1,706 Blog Entries: 2

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?
#40
02-09-2011, 02:03 PM
 ThatGuy Member Join Date: Aug 2010 College: I'm Old. Posts: 1,202

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

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 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 08:25 PM.

 -- Default Style - Fluid Width ---- Default Style - Fixed Width ---- Old Default Style ---- Easy on the eyes ---- Smooth Darkness ---- Chestnut ---- Apple-ish Style ---- If Apples were blue ---- If Apples were green ---- If Apples were purple ---- Halloween 2007 ---- B&W ---- Halloween ---- AO Christmas Theme ---- Turkey Day Theme ---- AO 2007 beta ---- 4th Of July Contact Us - Actuarial Outpost - Archive - Privacy Statement - Top