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;
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
add a comment |
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
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
add a comment |
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
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
sas
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 27 at 10:19
Chris LongChris Long
9904 silver badges13 bronze badges
9904 silver badges13 bronze badges
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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