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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You didn't post the output you need  yet.

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

Xia Keshan

View solution in original post

18 REPLIES 18
Ksharp
Super User

You didn't post the output you need  yet.

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

Xia Keshan

anitapamu2
Calcite | Level 5

can you do me small favour

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


above question i have used format time12.2.

Ksharp
Super User

Instead of it with    mmss12.2 

anitapamu2
Calcite | Level 5

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

anitapamu2
Calcite | Level 5

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

anitapamu2
Calcite | Level 5

Hi Xia Keshan,

the datavalues have been missed placed in the data set.

Capture_datavalues missed placed.PNG

anitapamu2
Calcite | Level 5

Hi Xia Keshan,

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

Capture_special cahr.PNG

Ksharp
Super User

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

pallis
Fluorite | Level 6

(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.

Ksharp
Super User

"(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

anitapamu2
Calcite | Level 5

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);


    Ksharp
    Super User

    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

    sas-innovate-2024.png

    Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

    Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

     

    Register now!

    How to Concatenate Values

    Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

    Find more tutorials on the SAS Users YouTube channel.

    Click image to register for webinarClick image to register for webinar

    Classroom Training Available!

    Select SAS Training centers are offering in-person courses. View upcoming courses for:

    View all other training opportunities.

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