I want to use the 'if ~ else if' function to perform some instructions if the first data is character and to perform other if they are numbersIt seems that I have a rounding issue with SAS PROC FORMATHow to pad out character fields in SAS?SAS:Scanning Variable-Length Records for a Specific Character StringUse function in SAS %doHow to call a macro variable based on a conditionIs sorting more favorable (efficient) in if-else statement?Beginner. Reading data in SAS (Reading date and 100 score issue)when to release the record in the input buffer with the @ in sas?Numbered range variables with character typeMultiple To clauses in Data step

Does this smartphone photo show Mars just below the Sun?

Does the United States guarantee any unique freedoms?

Where to pee in London?

How quickly could a country build a tall concrete wall around a city?

Erratic behavior by an internal employee against an external employee

In what sense are the equations of motion conserved by symmetries?

What does VB stand for?

Did Apollo leave poop on the moon?

Why do implementations of "stdint.h" disagree on the definition of UINT8_C?

Why do private jets such as Gulfstream fly higher than other civilian jets?

Where is the rule for moving slowly when searching for traps that’s referenced by Dungeon Delver?

Why should public servants be apolitical?

Traveling from Germany to other countries by train?

How do I say "Outdoor Pre-show"

Is it true that control+alt+delete only became a thing because IBM would not build Bill Gates a computer with a task manager button?

What was the first multiprocessor x86 motherboard?

WordCloud: do not eliminate duplicates

How to help new students accept function notation

Was there ever a difference between 'volo' and 'volo'?

How to realistically deal with a shield user?

What is the German idiom or expression for when someone is being hypocritical against their own teachings?

Our group keeps dying during the Lost Mine of Phandelver campaign. What are we doing wrong?

Colleagues speaking another language and it impacts work

sytemctl status log output



I want to use the 'if ~ else if' function to perform some instructions if the first data is character and to perform other if they are numbers


It seems that I have a rounding issue with SAS PROC FORMATHow to pad out character fields in SAS?SAS:Scanning Variable-Length Records for a Specific Character StringUse function in SAS %doHow to call a macro variable based on a conditionIs sorting more favorable (efficient) in if-else statement?Beginner. Reading data in SAS (Reading date and 100 score issue)when to release the record in the input buffer with the @ in sas?Numbered range variables with character typeMultiple To clauses in Data step






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















In SAS, I want to use the 'if ~ else if' function to perform some instructions if the first data is character and to perform other instructions if they are numbers.



I tried to use 'if ~ else if' statement but I do not know how to specify the conditional statement.




In this code,



data pr1;
input ~~~~
put profname$ course;
cards;
LEE 22
15 PARK
;
run;


I want to show this.



profname course
 LEE    22
 PARK    15


What can I put in '~~~' ??










share|improve this question


























  • You can definitely treat it in SAS (and Chris Long provides a nice solution below), but it would be wise to fix the order in the source system where the problem originates.

    – Vojta F
    Mar 27 at 12:44


















-1















In SAS, I want to use the 'if ~ else if' function to perform some instructions if the first data is character and to perform other instructions if they are numbers.



I tried to use 'if ~ else if' statement but I do not know how to specify the conditional statement.




In this code,



data pr1;
input ~~~~
put profname$ course;
cards;
LEE 22
15 PARK
;
run;


I want to show this.



profname course
 LEE    22
 PARK    15


What can I put in '~~~' ??










share|improve this question


























  • You can definitely treat it in SAS (and Chris Long provides a nice solution below), but it would be wise to fix the order in the source system where the problem originates.

    – Vojta F
    Mar 27 at 12:44














-1












-1








-1








In SAS, I want to use the 'if ~ else if' function to perform some instructions if the first data is character and to perform other instructions if they are numbers.



I tried to use 'if ~ else if' statement but I do not know how to specify the conditional statement.




In this code,



data pr1;
input ~~~~
put profname$ course;
cards;
LEE 22
15 PARK
;
run;


I want to show this.



profname course
 LEE    22
 PARK    15


What can I put in '~~~' ??










share|improve this question
















In SAS, I want to use the 'if ~ else if' function to perform some instructions if the first data is character and to perform other instructions if they are numbers.



I tried to use 'if ~ else if' statement but I do not know how to specify the conditional statement.




In this code,



data pr1;
input ~~~~
put profname$ course;
cards;
LEE 22
15 PARK
;
run;


I want to show this.



profname course
 LEE    22
 PARK    15


What can I put in '~~~' ??







sas






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 10:58









Chris Long

9904 silver badges13 bronze badges




9904 silver badges13 bronze badges










asked Mar 27 at 6:02









kkzznnkkzznn

11 bronze badge




11 bronze badge















  • You can definitely treat it in SAS (and Chris Long provides a nice solution below), but it would be wise to fix the order in the source system where the problem originates.

    – Vojta F
    Mar 27 at 12:44


















  • You can definitely treat it in SAS (and Chris Long provides a nice solution below), but it would be wise to fix the order in the source system where the problem originates.

    – Vojta F
    Mar 27 at 12:44

















You can definitely treat it in SAS (and Chris Long provides a nice solution below), but it would be wise to fix the order in the source system where the problem originates.

– Vojta F
Mar 27 at 12:44






You can definitely treat it in SAS (and Chris Long provides a nice solution below), but it would be wise to fix the order in the source system where the problem originates.

– Vojta F
Mar 27 at 12:44













1 Answer
1






active

oldest

votes


















1














There may be some clever INPUT statement magic you could do here, but I think the easiest, clearest solution would be to read in both columns as character data and then test them to see which column has which data:



data pr1 (keep = profname course);

* Declare PROFNAME as character and COURSE as numeric;
length profname $ 20 course 8;

* Read in two columns of data;
input col1 $ col2 $

if input(col1, ??best.) = . then do;
* If COL1 cannot be converted to a number, assume it is a name;
profname = col1;
course = input(col2, ??best.);
end; else do;
* Otherwise assume COL2 is the name;
profname = col2;
course = input(col1, ??best.);
end;

cards;
LEE 22
15 PARK
;
run;


The ?? modifiers in the INPUT() function suppress the usual warnings when a value can't be processed.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370734%2fi-want-to-use-the-if-else-if-function-to-perform-some-instructions-if-the-fi%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    There may be some clever INPUT statement magic you could do here, but I think the easiest, clearest solution would be to read in both columns as character data and then test them to see which column has which data:



    data pr1 (keep = profname course);

    * Declare PROFNAME as character and COURSE as numeric;
    length profname $ 20 course 8;

    * Read in two columns of data;
    input col1 $ col2 $

    if input(col1, ??best.) = . then do;
    * If COL1 cannot be converted to a number, assume it is a name;
    profname = col1;
    course = input(col2, ??best.);
    end; else do;
    * Otherwise assume COL2 is the name;
    profname = col2;
    course = input(col1, ??best.);
    end;

    cards;
    LEE 22
    15 PARK
    ;
    run;


    The ?? modifiers in the INPUT() function suppress the usual warnings when a value can't be processed.






    share|improve this answer





























      1














      There may be some clever INPUT statement magic you could do here, but I think the easiest, clearest solution would be to read in both columns as character data and then test them to see which column has which data:



      data pr1 (keep = profname course);

      * Declare PROFNAME as character and COURSE as numeric;
      length profname $ 20 course 8;

      * Read in two columns of data;
      input col1 $ col2 $

      if input(col1, ??best.) = . then do;
      * If COL1 cannot be converted to a number, assume it is a name;
      profname = col1;
      course = input(col2, ??best.);
      end; else do;
      * Otherwise assume COL2 is the name;
      profname = col2;
      course = input(col1, ??best.);
      end;

      cards;
      LEE 22
      15 PARK
      ;
      run;


      The ?? modifiers in the INPUT() function suppress the usual warnings when a value can't be processed.






      share|improve this answer



























        1












        1








        1







        There may be some clever INPUT statement magic you could do here, but I think the easiest, clearest solution would be to read in both columns as character data and then test them to see which column has which data:



        data pr1 (keep = profname course);

        * Declare PROFNAME as character and COURSE as numeric;
        length profname $ 20 course 8;

        * Read in two columns of data;
        input col1 $ col2 $

        if input(col1, ??best.) = . then do;
        * If COL1 cannot be converted to a number, assume it is a name;
        profname = col1;
        course = input(col2, ??best.);
        end; else do;
        * Otherwise assume COL2 is the name;
        profname = col2;
        course = input(col1, ??best.);
        end;

        cards;
        LEE 22
        15 PARK
        ;
        run;


        The ?? modifiers in the INPUT() function suppress the usual warnings when a value can't be processed.






        share|improve this answer













        There may be some clever INPUT statement magic you could do here, but I think the easiest, clearest solution would be to read in both columns as character data and then test them to see which column has which data:



        data pr1 (keep = profname course);

        * Declare PROFNAME as character and COURSE as numeric;
        length profname $ 20 course 8;

        * Read in two columns of data;
        input col1 $ col2 $

        if input(col1, ??best.) = . then do;
        * If COL1 cannot be converted to a number, assume it is a name;
        profname = col1;
        course = input(col2, ??best.);
        end; else do;
        * Otherwise assume COL2 is the name;
        profname = col2;
        course = input(col1, ??best.);
        end;

        cards;
        LEE 22
        15 PARK
        ;
        run;


        The ?? modifiers in the INPUT() function suppress the usual warnings when a value can't be processed.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 27 at 10:19









        Chris LongChris Long

        9904 silver badges13 bronze badges




        9904 silver badges13 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370734%2fi-want-to-use-the-if-else-if-function-to-perform-some-instructions-if-the-fi%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript