Help using Base SAS procedures

How to deal with this messy data

Reply
Frequent Learner
Posts: 1

How to deal with this messy data

11/12/2012 03:02 PM 1,275 ABS4_Binomials.aux
11/12/2012 03:02 PM 0 ABS4_Binomials.bbl
11/12/2012 03:02 PM 320 ABS4_Binomials.blg
11/12/2012 03:02 PM 43,917 ABS4_Binomials.log
11/12/2012 03:02 PM 444 ABS4_Binomials.nav
11/12/2012 03:02 PM 0 ABS4_Binomials.out
11/12/2012 03:02 PM 74,562 ABS4_Binomials.pdf
11/14/2012 12:18 PM 0 ABS4_Binomials.sas
11/12/2012 03:02 PM 0 ABS4_Binomials.snm
11/12/2012 03:02 PM 73,012 ABS4_Binomials.synctex
11/14/2012 12:18 PM 36,102 ABS4_Binomials.tex
11/12/2012 03:01 PM 36,108 ABS4_Binomials.tex.bak
11/12/2012 03:02 PM 41 ABS4_Binomials.toc
12/03/2012 03:47 PM 13,062,144 ABSProjects.sdf
12/03/2012 01:25 PM 4,275 ABSProjects.sln
11/12/2012 03:03 PM 528,361 ABS_Binomial.pdf
11/09/2012 12:52 PM 510,603 AveEffects1Way2by2_D.sas
11/29/2012 01:26 PM 631,906 AveEffects1Way_School.sas
11/01/2012 06:09 PM <DIR>Debug
11/28/2012 10:43 AM 1,774 GAUSS.txt
12/03/2012 01:14 PM <DIR>ipch
11/09/2012 05:51 PM 209 LightSpeed.txt
11/09/2012 12:53 PM 185,862 MeanEffects1Way2by2_D.pdf
11/09/2012 12:39 PM 168,931 MeanEffects1Way_School.pdf
11/14/2012 06:06 PM 9,891 MUSlides_LightSpeed.aux
11/14/2012 06:06 PM 0 MUSlides_LightSpeed.bbl
11/14/2012 06:06 PM 340 MUSlides_LightSpeed.blg
11/14/2012 06:06 PM 48,833 MUSlides_LightSpeed.log
11/14/2012 06:06 PM 6,684 MUSlides_LightSpeed.nav
11/14/2012 06:06 PM 0 MUSlides_LightSpeed.out
11/14/2012 06:06 PM 515,997 MUSlides_LightSpeed.pdf
11/14/2012 06:06 PM 0 MUSlides_LightSpeed.snm
11/14/2012 06:06 PM 1,203,852 MUSlides_LightSpeed.synctex
11/14/2012 06:06 PM 41,007 MUSlides_LightSpeed.tex
11/14/2012 06:03 PM 41,079 MUSlides_LightSpeed.tex.bak
11/14/2012 06:06 PM 41 MUSlides_LightSpeed.toc
11/14/2012 01:28 PM 6,747 MU_LightSpeed.aux
11/14/2012 01:28 PM 0 MU_LightSpeed.bbl
11/14/2012 01:28 PM 316 MU_LightSpeed.blg
11/14/2012 01:28 PM 46,946 MU_LightSpeed.log
11/14/2012 01:28 PM 4,404 MU_LightSpeed.nav
11/14/2012 01:28 PM 0 MU_LightSpeed.out
11/14/2012 01:28 PM 360,498 MU_LightSpeed.pdf
11/14/2012 06:06 PM 1,142,373 MU_LightSpeed.sas
11/14/2012 01:28 PM 0 MU_LightSpeed.snm
11/14/2012 01:28 PM 778,444 MU_LightSpeed.synctex
11/14/2012 01:28 PM 48,115 MU_LightSpeed.tex
11/14/2012 12:18 PM 279,898 MU_LightSpeed.tex.bak
11/14/2012 01:28 PM 41 MU_LightSpeed.toc
12/03/2012 02:28 PM <DIR>Release
11/07/2012 05:59 PM 114 School.txt
11/09/2012 02:47 PM 1,130,588 SimuEffects1Way2by2_D.pdf
11/09/2012 12:52 PM 675,924 SimuEffects1Way2by2_D.sas
11/09/2012 12:39 PM 560,392 SimuEffects1Way_School.pdf
11/29/2012 01:26 PM 310,182 SimuEffects1Way_School.sas
11/12/2012 10:20 AM <DIR>T1WayRandEffects
11/12/2012 10:20 AM <DIR>T1WayRandEffectsFor2by2
11/12/2012 10:20 AM <DIR>TBS2
11/12/2012 11:58 AM <DIR>TBS4_Binomial
11/12/2012 10:20 AM <DIR>TBS4_Normal
11/26/2012 11:57 AM <DIR>TGaussHermite
12/03/2012 01:07 PM <DIR>TMode4_Cauchy
12/03/2012 01:25 PM <DIR>TNormal_on_Cauchy

my data is like this, I need to creat dataset that contains the date, the filename and the type. By saying type, I mean it's like .txt.pdf. The <DIR> type is just killing me,  Can someone help me out please?Thank you!

Respected Advisor
Posts: 4,935

Re: How to deal with this messy data

Posted in reply to MindyJiang

Check _infile_ before deciding how to read each record:

 

data files(keep=date date file ext) dirs(keep=date dir);
length fileext dir file $128 ext $16 t $8;
infile datalines; /* <- nane your fileref here */
input @;
if index(_infile_, "<DIR>") = 0 then do;
    input d :mmddyy10. t & @21 num :comma. fileext;
    time = input(t, time8.);
    date = dhms(d,hour(time),minute(time),second(time));
    file = scan(fileext,1, ".");
    ext = scan(fileext, 2, ".");
    output files;
    end;
else do;
    input d :mmddyy10. t & @21 dir;
    time = input(t, time8.);
    date = dhms(d,hour(time),minute(time),second(time));
    dir = scan(dir, 2, ">");
    output dirs;
    end;
format date datetime15.;
datalines;
11/12/2012 03:02 PM 1,275 ABS4_Binomials.aux
11/12/2012 03:02 PM 0 ABS4_Binomials.bbl
11/12/2012 03:02 PM 320 ABS4_Binomials.blg
11/12/2012 03:02 PM 43,917 ABS4_Binomials.log
11/12/2012 03:02 PM 444 ABS4_Binomials.nav
11/12/2012 03:02 PM 0 ABS4_Binomials.out
11/12/2012 03:02 PM 74,562 ABS4_Binomials.pdf
11/14/2012 12:18 PM 0 ABS4_Binomials.sas
11/12/2012 03:02 PM 0 ABS4_Binomials.snm
11/12/2012 03:02 PM 73,012 ABS4_Binomials.synctex
11/14/2012 12:18 PM 36,102 ABS4_Binomials.tex
11/12/2012 03:01 PM 36,108 ABS4_Binomials.tex.bak
11/12/2012 03:02 PM 41 ABS4_Binomials.toc
12/03/2012 03:47 PM 13,062,144 ABSProjects.sdf
12/03/2012 01:25 PM 4,275 ABSProjects.sln
11/12/2012 03:03 PM 528,361 ABS_Binomial.pdf
11/09/2012 12:52 PM 510,603 AveEffects1Way2by2_D.sas
11/29/2012 01:26 PM 631,906 AveEffects1Way_School.sas
11/01/2012 06:09 PM <DIR>Debug
11/28/2012 10:43 AM 1,774 GAUSS.txt
12/03/2012 01:14 PM <DIR>ipch
11/09/2012 05:51 PM 209 LightSpeed.txt
11/09/2012 12:53 PM 185,862 MeanEffects1Way2by2_D.pdf
11/09/2012 12:39 PM 168,931 MeanEffects1Way_School.pdf
11/14/2012 06:06 PM 9,891 MUSlides_LightSpeed.aux
11/14/2012 06:06 PM 0 MUSlides_LightSpeed.bbl
11/14/2012 06:06 PM 340 MUSlides_LightSpeed.blg
11/14/2012 06:06 PM 48,833 MUSlides_LightSpeed.log
11/14/2012 06:06 PM 6,684 MUSlides_LightSpeed.nav
11/14/2012 06:06 PM 0 MUSlides_LightSpeed.out
11/14/2012 06:06 PM 515,997 MUSlides_LightSpeed.pdf
11/14/2012 06:06 PM 0 MUSlides_LightSpeed.snm
11/14/2012 06:06 PM 1,203,852 MUSlides_LightSpeed.synctex
11/14/2012 06:06 PM 41,007 MUSlides_LightSpeed.tex
11/14/2012 06:03 PM 41,079 MUSlides_LightSpeed.tex.bak
11/14/2012 06:06 PM 41 MUSlides_LightSpeed.toc
11/14/2012 01:28 PM 6,747 MU_LightSpeed.aux
11/14/2012 01:28 PM 0 MU_LightSpeed.bbl
11/14/2012 01:28 PM 316 MU_LightSpeed.blg
11/14/2012 01:28 PM 46,946 MU_LightSpeed.log
11/14/2012 01:28 PM 4,404 MU_LightSpeed.nav
11/14/2012 01:28 PM 0 MU_LightSpeed.out
11/14/2012 01:28 PM 360,498 MU_LightSpeed.pdf
11/14/2012 06:06 PM 1,142,373 MU_LightSpeed.sas
11/14/2012 01:28 PM 0 MU_LightSpeed.snm
11/14/2012 01:28 PM 778,444 MU_LightSpeed.synctex
11/14/2012 01:28 PM 48,115 MU_LightSpeed.tex
11/14/2012 12:18 PM 279,898 MU_LightSpeed.tex.bak
11/14/2012 01:28 PM 41 MU_LightSpeed.toc
12/03/2012 02:28 PM <DIR>Release
11/07/2012 05:59 PM 114 School.txt
11/09/2012 02:47 PM 1,130,588 SimuEffects1Way2by2_D.pdf
11/09/2012 12:52 PM 675,924 SimuEffects1Way2by2_D.sas
11/09/2012 12:39 PM 560,392 SimuEffects1Way_School.pdf
11/29/2012 01:26 PM 310,182 SimuEffects1Way_School.sas
11/12/2012 10:20 AM <DIR>T1WayRandEffects
11/12/2012 10:20 AM <DIR>T1WayRandEffectsFor2by2
11/12/2012 10:20 AM <DIR>TBS2
11/12/2012 11:58 AM <DIR>TBS4_Binomial
11/12/2012 10:20 AM <DIR>TBS4_Normal
11/26/2012 11:57 AM <DIR>TGaussHermite
12/03/2012 01:07 PM <DIR>TMode4_Cauchy
12/03/2012 01:25 PM <DIR>TNormal_on_Cauchy
;
PG
Ask a Question
Discussion stats
  • 1 reply
  • 238 views
  • 0 likes
  • 2 in conversation