DATA Step, Macro, Functions and more

FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Accepted Solution Solved
Reply
Contributor
Posts: 34
Accepted Solution

FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

data yourdata;
  format finaltime time12.2;
  infile cards dlm=',';
  input age team finaltimec $ score;
  finaltime = input(finaltimec,?? hhmmss.);
  drop finaltimec;
  cards;
20,1,55.49,1
22,1,1:23.57,2
34,1,NA,3
19,2,32.22,4
55,3,5:38.43,5
17,3,12:52.17,6
31,3,25.13,7
;
run;VARAIABLE IT


Accepted Solutions
Solution
‎03-09-2015 09:16 AM
Super User
Posts: 10,023

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Posted in reply to anitapamu2

You didn't post the output you need  yet.

finaltime = input(finaltimec,?? stimer.);

Xia Keshan

View solution in original post


All Replies
Solution
‎03-09-2015 09:16 AM
Super User
Posts: 10,023

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Posted in reply to anitapamu2

You didn't post the output you need  yet.

finaltime = input(finaltimec,?? stimer.);

Xia Keshan

Contributor
Posts: 34

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

can you do me small favour

I want finaltime in the format of mm:ss.dd  .


above question i have used format time12.2.

Super User
Posts: 10,023

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Posted in reply to anitapamu2

Instead of it with    mmss12.2 

Contributor
Posts: 34

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Hi Xia Keshan,

Can you please send Me BASE SAS & ADV SAS NOTES and Doc.which really helpful or 2 to 3 yrs of experience guys.

anitapamu2@yahoo.com

Thanks,

Anita

Super User
Posts: 7,766

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Posted in reply to anitapamu2

Suppressing error messages and notes with the "??" modifier is NOT, I repeat NOT, helpful in locating problems!

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 34

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Posted in reply to anitapamu2

Hi ,

we missing the variable called Place.and the place contain '--' that special character should present in the data set along with the variables.Capture.PNG

Contributor
Posts: 34

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Posted in reply to anitapamu2

Hi Xia Keshan,

the datavalues have been missed placed in the data set.

Capture_datavalues missed placed.PNG

Contributor
Posts: 34

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Posted in reply to anitapamu2

Hi Xia Keshan,

In the variable Stroke and Points we can see the special character ' [] ' .

Capture_special cahr.PNG

Super User
Posts: 10,023

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Posted in reply to anitapamu2

OK. Here is :

data want;

infile 'c:\temp\MeetResults_SourceData_2.txt' truncover  ;

input @;

length Gender     age_group    Distance    course     Stroke $ 100;

retain Gender     age_group    Distance    course     Stroke;

if prxmatch('/^\w+/',_infile_) then do;

  input  (Gender     age_group    Distance    course     Stroke ) ($);

end;

else if prxmatch('/\w+,/',_infile_) then do;

  input places $ 1-4 Name  $ 5-28 Age $ 29-33 Team   $ 34-61 Finals $ 62-73 Points $ 74-80;

  output;

end;

run;

Message was edited by: xia keshan

Message was edited by: xia keshan

Contributor
Posts: 34

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Thank you !!

Contributor
Posts: 71

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

(1) if prxmatch('/^\w+/',_infile_) then do;

  input  (Gender     age_group    Distance    course     Stroke ) ($);

end;

(2) else if prxmatch('/\w+,/',_infile_) then do;

  input places $ 1-4 Name  $ 5-28 Age $ 29-33 Team   $ 34-61 Finals $ 62-73 Points $ 74-80;

  output;

end;

Please correct my understanding if i'm wrong.

(1) Here you are identifying that first letter(string) starts with character and you are specifying it as character

(2) Here you are mentioning the variables with lengths

what i observed here is is she cresting two different data sets?

Whats she wants i didn't understand she just mentioned that in data set she find special characters [].

I'm totally blank. can you explain please.

Super User
Posts: 10,023

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

"(1) Here you are identifying that first letter(string) starts with character and you are specifying it as character"

Yes. The pattern match the line which starts with a word .

(2) Here you are mentioning the variables with lengths

No. I just match pattern a word plus a comma . or just match a comma only.

else if findc(',',_infile_) then do;

"what i observed here is is she cresting two different data sets?"

No. They all are a table he want.

"Whats she wants i didn't understand she just mentioned that in data set she find special characters []."

That the first code of mine I generated ,didn't post here ,just email him .

you saw a [] ,I think it is a carriage character '0D'x .

Xia Keshan

Contributor
Posts: 34

Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

Posted in reply to anitapamu2

Hi All,

I have created a small macro to  *Converting all character values to uppercase

%macro UPCASE_Var(_a_infile_,_a_outfile_);

data &_a_outfile_.;

set &_a_infile_.;

array Chars

  • _character_;
  • do i = 1 to dim(Chars);

    Chars = upcase(Chars);

    end;

    drop i;

    run;

    %mend;

    %UPCASE_Var(sashelp.class,test1234);

    But can some help me to write for all SASDATA SET in the Libname


    %macro UPCASE_Var(libname);

    code here....

    %mend;


    % UPCASE_Var(libname);


    Super User
    Posts: 10,023

    Re: FINALTIME VARIABLE IS NOT LOADED .CAN SOME LOOK INTO IT

    Posted in reply to anitapamu2

    No need for Macro .

    Here is an example , copying all the tables in SASHELP into WORK library.

    filename y temp;
    proc cport library=sashelp file=y memtype=data outtype=upcase;run;
    proc cimport library=work infile=y;run;
    
    
    

    Xia Keshan

    🔒 This topic is solved and locked.

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

    Discussion stats
    • 18 replies
    • 461 views
    • 5 likes
    • 4 in conversation