본문 바로가기
반응형

spss49

통계프로그램 전처리 비교 (Proc sql, SAS, SPSS, R 프로그래밍, R Tidyverse, Python Pandas, Python Dfply) 통계프로그램 전처리 비교 (Proc sql, SAS, SPSS, R 프로그래밍, R Tidyverse, Python Pandas, Python Dfply) - 데이터 획득 1. 예제 텍스트 파일 2. DATA EDITOR 3. 쉼표(,) 구분자 텍스트 파일 읽기 4. 프로그램 내에서 TEXT 데이터 읽기 5. 고정 길이 텍스트 파일 읽기 (한줄에 하나의 관측치) 6. 고정 길이 텍스트 파일 읽기 (두개의 행에 하나의 관측치존재) 7. IMPORTING DATA FROM SAS 8. IMPORTING DATA FROM SPSS 9. EXPORTING DATA TO SAS & SPSS DATA SETS - 변수와 관측치 선택 1. 변수 선택하기 2. 관측치 선택( WHERE, IF, SELECT IF ) 3.. 2022. 1. 19.
15. 변수 라벨(Variable Labels) 통계프로그램 비교 시리즈 – 15. 변수 라벨(Variable Labels) 1. Proc SQL SAS Programming proc sql; select id, workshop , gender , q1 label='The instructor was well prepared.', q2 label='The instructor communicated well.', q3 label='The course materials were helpful.', q4 label='Overall, I found this workshop useful.' from BACK.mydata; quit; Results The Overall, The The course I found instructor instructor materia.. 2022. 1. 19.
14. 변수 특성에 따른 통계량 일괄 처리 & Value Labels Or Formats(& Measurement Level)) 14. 변수 특성에 따른 통계량 일괄 처리 & Value Labels Or Formats(& Measurement Level)) 1. Proc SQL SAS Program to Assign Value Labels (formats) SAS Programming options linesize=150; * SAS Program to Assign Value Labels (formats); PROC FORMAT; VALUE workshop_f 1="Control" 2="Treatment"; VALUE $gender_f "m"="Male" "f"="Female"; VALUE agreement 1='Strongly Disagree' 2='Disagree' 3='Neutral' 4='Agree' 5='Strongly .. 2022. 1. 17.
통계프로그램 비교 시리즈 - 13. 데이터 프레임 정렬과 중복제거-Sorting & duplicate 13. 데이터 프레임 정렬과 중복제거-Sorting & duplicate 1. Proc SQL Order by 구분을 이용하여 데이터 소트; SAS Programming proc sql; select * from BACK.mydata order by workshop; quit; Results id workshop gender q1 q2 q3 q4 -------------------------------------------------------------- 3 1 f 2 2 4 3 5 1 m 4 5 2 4 7 1 m 5 3 4 4 1 1 f 1 1 5 1 6 2 m 5 4 5 5 2 2 f 2 1 4 1 4 2 f 3 1 . 3 8 2 m 4 5 5 5 SAS Programming proc sql; se.. 2022. 1. 15.
[데이터 관리] 11. Aggregating Or Summarizing 데이터 [데이터 관리] 11. Aggregating Or Summarizing 데이터 1. Proc SQL SAS Programming proc sql; create table withmooc as select GENDER, MEAN(q1) as q1_mean from BACK.mydata group by GENDER; select * from withmooc; quit; Results gender q1_mean ------------------ f 2 m 4.5 SAS Programming proc sql; create table withmooc as select WORKSHOP, GENDER, MEAN(q1) as q1_mean from BACK.mydata group by 1,2; select * from.. 2022. 1. 15.
[데이터 관리] 10. Joining & Merging 데이터 프레임 [데이터 관리] 10. Joining & Merging 데이터 프레임 1. Proc SQL 중복 시 SAS의 MERGE와 차이 발생 SAS Programming proc sql; create table myleft as select id,workshop,gender,q1,q2 from BACK.mydata; create table myright as select id,workshop,q3,q4 from BACK.mydata; create table myshort(where=(NUM 2022. 1. 14.
[데이터 관리] 9. Stacking & Concatenating & Adding Data Sets [데이터 관리] 9. Stacking & Concatenating & Adding Data Sets (Union / 상하 결합) 1. Proc SQL Stacking(Unoin) 작업을 위하여 실습 데이터 생성 SAS Programming proc sql; create table males as select * from BACK.mydata where gender='m'; select * from males; quit; Results id workshop gender q1 q2 q3 q4 -------------------------------------------------------------- 5 1 m 4 5 2 4 6 2 m 5 4 5 5 7 1 m 5 3 4 4 8 2 m 4 5 5 5 Sta.. 2022. 1. 14.
[데이터 관리] 8. By 또는 Split 파일 프로세싱 [데이터 관리] 8. By 또는 Split 파일 프로세싱 1. Proc SQL By 또는 Split 파일 프로세싱을 위한 PROC SQL 프로그램 Group by 옵션을 이용하여, 성별을 기준으로 지정된 각 함수 처리 SAS Programming proc sql; create table withmooc as select gender, sum(q1) as q1_sum, mean(q2) as q2_mean, min(q3) as q3_min, max(q4) as q4_max from BACK.mydata a group by gender; select * from withmooc; quit; Results gender q1_sum q2_mean q3_min q4_max -----------------------.. 2022. 1. 11.
[데이터 관리] 7. 변수 Keeping과 Dropping [데이터 관리] 7. 변수 Keeping과 Dropping 1. Proc SQL 변수 Keeping과 Droping을 위한 PROC SQL 프로그램. SAS Programming * Select 문에서 변수 선택; proc sql; create table withmooc as select id, workshop, gender, q1, q2 from BACK.mydata a; select * from withmooc; quit; * 입력데이터의 변수 선택; proc sql; create table withmooc as select a.* from BACK.mydata(KEEP =id workshop gender q1 q2) a; select * from withmooc; quit; * 출력 데이터의 변수 .. 2022. 1. 10.
[데이터 관리] 6. 관측값 포맷팅 & 관측값 일괄 변경하기 [데이터 관리] 6. 관측값 포맷팅 & 관측값 일괄 변경하기 1. Proc SQL CASE함수를 이용하여 RECODING; SAS Programming options linesize=120; proc sql; create table withmooc as select a.*, case q1 when 1 then 2 when 5 then 4 else q1 end as qr1, case q2 when 1 then 2 when 5 then 4 else q2 end as qr2, case q3 when 1 then 2 when 5 then 4 else q3 end as qr3, case q4 when 1 then 2 when 5 then 4 else q4 end as qr4 from BACK.mydata a; s.. 2022. 1. 10.
통계프로그램 비교 시리즈 – [데이터 관리] 5. 변수명 변경(Rename) [데이터 관리] 5. 변수명 변경(Rename) 1. Proc SQL 변수명 변경을 위한 SQL(PROC SQL)프로그램. 일반 오라클에서는 상단의 별칭(as)을 통한 변수명을 새롭게 지정하여서 변경할 수 있다. SAS Programming proc sql; create table withmooc as select id, workshop, gender, q1 as x1, q2 as x2, q3 as x3, q4 as x4 from BACK.mydata; quit; proc sql; create table withmooc as select * from BACK.mydata(rename=(q1-q4=x1-x4)); quit; proc sql; create table withmooc(rename=(q1-q4=.. 2022. 1. 10.
통계프로그램 비교 시리즈 – [데이터 관리] 4. 다중 조건에 의한 변환 [데이터 관리] 4. 다중 조건에 의한 변환 1. Proc SQL case when문을 통하여 IF문을 대체한다. 단, 복합 조건에 대한 적용은 불가. SAS Programming proc sql; select id, workshop,gender,q1,q2,q3,q4, case when gender='m' then (20*q1)+q2 else (2*q1)+q2 end "score1", case when gender='m' then (30*q1)+q2 else (3*q1)+q2 end "score2" from back.mydata; quit; Results id workshop gender q1 q2 q3 q4 score1 score2 ---------------------------------------.. 2022. 1. 10.
반응형