SAS Restructure Data
I need help restructuring the data. My Table looks like this
NameHead Department Per_test Per_Delta Per_DB Per_Vul
Nancy Health 55 33.2 33 63
Jim Air 25 22.8 23 11
Shu Water 26 88.3 44 12
Dick Electricity 77 55.9 66 10
Elena General 88 22 67 9
Nancy Internet 66 12 44 79
And I want my table to look like this
NameHead Nancy Jim Shu Dick Elena Nancy
Department Health Air Water Electricity General Internet
Per_test 55 25 26 77 88 66
Per_Delta 33.2 22.8 88.3 55.9 22 12
PerDB 33 23 44 66 67 44
Per_Vul 63 11 12 10 9 79
I tried proc transpose but couldnt get the desired result. Please help!
Thanks!
sas transpose
add a comment |
I need help restructuring the data. My Table looks like this
NameHead Department Per_test Per_Delta Per_DB Per_Vul
Nancy Health 55 33.2 33 63
Jim Air 25 22.8 23 11
Shu Water 26 88.3 44 12
Dick Electricity 77 55.9 66 10
Elena General 88 22 67 9
Nancy Internet 66 12 44 79
And I want my table to look like this
NameHead Nancy Jim Shu Dick Elena Nancy
Department Health Air Water Electricity General Internet
Per_test 55 25 26 77 88 66
Per_Delta 33.2 22.8 88.3 55.9 22 12
PerDB 33 23 44 66 67 44
Per_Vul 63 11 12 10 9 79
I tried proc transpose but couldnt get the desired result. Please help!
Thanks!
sas transpose
I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.
– Tom
Nov 23 '18 at 21:09
I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.
– JCP
Nov 23 '18 at 21:14
What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?
– Tom
Nov 23 '18 at 21:18
add a comment |
I need help restructuring the data. My Table looks like this
NameHead Department Per_test Per_Delta Per_DB Per_Vul
Nancy Health 55 33.2 33 63
Jim Air 25 22.8 23 11
Shu Water 26 88.3 44 12
Dick Electricity 77 55.9 66 10
Elena General 88 22 67 9
Nancy Internet 66 12 44 79
And I want my table to look like this
NameHead Nancy Jim Shu Dick Elena Nancy
Department Health Air Water Electricity General Internet
Per_test 55 25 26 77 88 66
Per_Delta 33.2 22.8 88.3 55.9 22 12
PerDB 33 23 44 66 67 44
Per_Vul 63 11 12 10 9 79
I tried proc transpose but couldnt get the desired result. Please help!
Thanks!
sas transpose
I need help restructuring the data. My Table looks like this
NameHead Department Per_test Per_Delta Per_DB Per_Vul
Nancy Health 55 33.2 33 63
Jim Air 25 22.8 23 11
Shu Water 26 88.3 44 12
Dick Electricity 77 55.9 66 10
Elena General 88 22 67 9
Nancy Internet 66 12 44 79
And I want my table to look like this
NameHead Nancy Jim Shu Dick Elena Nancy
Department Health Air Water Electricity General Internet
Per_test 55 25 26 77 88 66
Per_Delta 33.2 22.8 88.3 55.9 22 12
PerDB 33 23 44 66 67 44
Per_Vul 63 11 12 10 9 79
I tried proc transpose but couldnt get the desired result. Please help!
Thanks!
sas transpose
sas transpose
edited Nov 23 '18 at 21:10
JCP
asked Nov 23 '18 at 20:46
JCPJCP
64
64
I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.
– Tom
Nov 23 '18 at 21:09
I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.
– JCP
Nov 23 '18 at 21:14
What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?
– Tom
Nov 23 '18 at 21:18
add a comment |
I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.
– Tom
Nov 23 '18 at 21:09
I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.
– JCP
Nov 23 '18 at 21:14
What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?
– Tom
Nov 23 '18 at 21:18
I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.
– Tom
Nov 23 '18 at 21:09
I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.
– Tom
Nov 23 '18 at 21:09
I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.
– JCP
Nov 23 '18 at 21:14
I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.
– JCP
Nov 23 '18 at 21:14
What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?
– Tom
Nov 23 '18 at 21:18
What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?
– Tom
Nov 23 '18 at 21:18
add a comment |
1 Answer
1
active
oldest
votes
PROC TRANSPOSE does exactly what you want. You must include a VAR
statement if you want to include the character variables.
proc transpose data=have out=want;
var _all_;
run;
Note that you cannot have variables that do not have names. Here is what the dataset looks like.
Obs _NAME_ COL1 COL2 COL3 COL4 COL5 COL6
1 NameHead Nancy Jim Shu Dick Elena Nancy
2 Department Health Air Water Electricity General Internet
3 Percent_test 55 25 26 77 88 66
4 Percent_Delta 33.2 22.8 88.3 55.9 22 12
5 Percent_DB 33 23 44 66 67 44
6 Percent_Vul 63 11 12 10 9 79
I actually want column names as NameHead ....sorry not the first row.
– JCP
Nov 23 '18 at 21:38
Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.
– Tom
Nov 23 '18 at 21:49
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%2f53452767%2fsas-restructure-data%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
PROC TRANSPOSE does exactly what you want. You must include a VAR
statement if you want to include the character variables.
proc transpose data=have out=want;
var _all_;
run;
Note that you cannot have variables that do not have names. Here is what the dataset looks like.
Obs _NAME_ COL1 COL2 COL3 COL4 COL5 COL6
1 NameHead Nancy Jim Shu Dick Elena Nancy
2 Department Health Air Water Electricity General Internet
3 Percent_test 55 25 26 77 88 66
4 Percent_Delta 33.2 22.8 88.3 55.9 22 12
5 Percent_DB 33 23 44 66 67 44
6 Percent_Vul 63 11 12 10 9 79
I actually want column names as NameHead ....sorry not the first row.
– JCP
Nov 23 '18 at 21:38
Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.
– Tom
Nov 23 '18 at 21:49
add a comment |
PROC TRANSPOSE does exactly what you want. You must include a VAR
statement if you want to include the character variables.
proc transpose data=have out=want;
var _all_;
run;
Note that you cannot have variables that do not have names. Here is what the dataset looks like.
Obs _NAME_ COL1 COL2 COL3 COL4 COL5 COL6
1 NameHead Nancy Jim Shu Dick Elena Nancy
2 Department Health Air Water Electricity General Internet
3 Percent_test 55 25 26 77 88 66
4 Percent_Delta 33.2 22.8 88.3 55.9 22 12
5 Percent_DB 33 23 44 66 67 44
6 Percent_Vul 63 11 12 10 9 79
I actually want column names as NameHead ....sorry not the first row.
– JCP
Nov 23 '18 at 21:38
Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.
– Tom
Nov 23 '18 at 21:49
add a comment |
PROC TRANSPOSE does exactly what you want. You must include a VAR
statement if you want to include the character variables.
proc transpose data=have out=want;
var _all_;
run;
Note that you cannot have variables that do not have names. Here is what the dataset looks like.
Obs _NAME_ COL1 COL2 COL3 COL4 COL5 COL6
1 NameHead Nancy Jim Shu Dick Elena Nancy
2 Department Health Air Water Electricity General Internet
3 Percent_test 55 25 26 77 88 66
4 Percent_Delta 33.2 22.8 88.3 55.9 22 12
5 Percent_DB 33 23 44 66 67 44
6 Percent_Vul 63 11 12 10 9 79
PROC TRANSPOSE does exactly what you want. You must include a VAR
statement if you want to include the character variables.
proc transpose data=have out=want;
var _all_;
run;
Note that you cannot have variables that do not have names. Here is what the dataset looks like.
Obs _NAME_ COL1 COL2 COL3 COL4 COL5 COL6
1 NameHead Nancy Jim Shu Dick Elena Nancy
2 Department Health Air Water Electricity General Internet
3 Percent_test 55 25 26 77 88 66
4 Percent_Delta 33.2 22.8 88.3 55.9 22 12
5 Percent_DB 33 23 44 66 67 44
6 Percent_Vul 63 11 12 10 9 79
edited Nov 23 '18 at 21:26
answered Nov 23 '18 at 21:16
TomTom
22.8k2718
22.8k2718
I actually want column names as NameHead ....sorry not the first row.
– JCP
Nov 23 '18 at 21:38
Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.
– Tom
Nov 23 '18 at 21:49
add a comment |
I actually want column names as NameHead ....sorry not the first row.
– JCP
Nov 23 '18 at 21:38
Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.
– Tom
Nov 23 '18 at 21:49
I actually want column names as NameHead ....sorry not the first row.
– JCP
Nov 23 '18 at 21:38
I actually want column names as NameHead ....sorry not the first row.
– JCP
Nov 23 '18 at 21:38
Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.
– Tom
Nov 23 '18 at 21:49
Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.
– Tom
Nov 23 '18 at 21:49
add a comment |
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%2f53452767%2fsas-restructure-data%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
I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.
– Tom
Nov 23 '18 at 21:09
I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.
– JCP
Nov 23 '18 at 21:14
What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?
– Tom
Nov 23 '18 at 21:18