04-07-2016 11:21 AM
I'm trying to combine two datasets, two from the prelimenary network drive (P) and one from the final network drive (Q, the backend server drive).
I prepared and cleaned the 2 datasets from P and merged them with the Q data set (which was not touched) then I saved the merged set in the P drive. What happened is that all the datasets related to the merged data set do not show up (I mean the data observations, only variables show up) when I opened them in SAS. But when I tried to read them in SAS, all proc contents, proq freqs work, also all the queries still work perfectly on the related website. This means the data is still there but it doesn't show up. Yesterday, I had the same problem and I'm not sure what I did and it showed the obseravations back. Today when I was still manipulating the data and saved the merged data set I had the same problem again. I have no clue on what's happening, I concatenated two other datasets before and didn't have any problem, could it be the merging the datasets and if that is the case, how should I solve it.
04-07-2016 11:59 AM
04-07-2016 12:35 PM
Thank you for your reply, here's the code I used.
libname final "Q:\sasData\final";
options nocenter nonumber nodate linesize=125 pagesize=4000 formchar=" " ;
libname prelim "P:\BRFSS\data\ORIG\CDC";
set prelim.nm13finl prelim.nm14finl;
set brfss2 (rename=(iyear = YEAR decide = _DiffDecide));
set brfss3 (keep = _DiffDecide RRCLASS2 RRATWRK2 RRCOGNT2 RREMTSM2 RRHCARE3 RRPHYSM2 YEAR SEQNO);
year1 = input(year,4.0);
rename year1 = YEAR;
_RRCLASS = .;
if RRCLASS2 = 6 then _RRCLASS = 1;
else if RRCLASS2 = 4 OR RRCLASS2 = 5 then _RRCLASS = 2;
else if RRCLASS2 = 2 then _RRCLASS = 3;
else if RRCLASS2 = 3 then _RRCLASS = 4;
else if RRCLASS2 = 1 then _RRCLASS = 5;
LABEL _RRCLASS = "People Classify you: 1=American Indian/Alaska Native, 2=Asian/Pacific Islander, 3=Black/African American, 4=Hispanic, 5=White";
_RRCOGNT = .;
if RRCOGNT2 = 6 then _RRCOGNT = 1;
else if RRCOGNT2 = 5 then _RRCOGNT = 2;
else if RRCOGNT2 = 4 then _RRCOGNT = 3;
else if RRCOGNT2 = 3 then _RRCOGNT = 4;
else if RRCOGNT2 = 2 then _RRCOGNT = 5;
else if RRCOGNT2 = 1 then _RRCOGNT = 6;
LABEL _RRCOGNT = "Thinking About Race: 1=Once an Hour, 2=Once a Day, 3=Once a Week, 4=Once a Month, 5= Once a Year, 6= Never";
_RRATWRK = .;
if RRATWRK2 = 1 then _RRATWRK = 4;
else if RRATWRK2 = 2 then _RRATWRK = 2;
else if RRATWRK2 = 3 then _RRATWRK = 1;
else if RRATWRK2 = 4 then _RRATWRK = 3;
else if RRATWRK2 = 5 then _RRATWRK = 5;
LABEL _RRATWRK = "Feel Treated at Work Due to Race: 1=Better Than Other Races, 2=Same as Other Races, 3=Worse Than Some Races, Better Than Others, 4=Worse Than Other Races, 5=Only Encountered People of The Same Race";
_RRHCARE = .;
if RRHCARE3 = 1 then _RRHCARE = 4;
else if RRHCARE3 = 2 then _RRHCARE = 2;
else if RRHCARE3 = 3 then _RRHCARE = 1;
else if RRHCARE3 = 4 then _RRHCARE = 3;
else if RRHCARE3 = 5 then _RRHCARE = 5;
else if RRHCARE3 = 6 then _RRHCARE = 6;
LABEL _RRHCARE = "Experience at Health Care: 1=Better Than Other Races, 2=Same as Other Races, 3=Worse Than Some Races, Better Than Others, 4=Worse Than Other Races, 5=Only Encountered People of The Same Race, 6=No Health Care in Past 12 Months";
_RRPHYSM = .;
if RRPHYSM2 = 1 then _RRPHYSM = 2;
else if RRPHYSM2 = 2 then _RRPHYSM = 1;
LABEL _RRPHYSM = "Felt Physical Symptoms Due to Race: 1=no, 2=yes";
_RREMTSM = .;
if RREMTSM2 = 1 then _RREMTSM = 2;
else if RREMTSM2 = 2 then _RREMTSM = 1;
LABEL _RREMTSM = "Felt Emotionally Upset Due to Race: 1=no, 2=yes";
data brfss6 (keep = _DiffDecide _RRCLASS _RRATWRK _RRCOGNT _RREMTSM _RRHCARE _RRPHYSM YEAR SEQNO);
set brfss5 (drop = RRCLASS2 RRATWRK2 RRCOGNT2 RREMTSM2 RRHCARE3 RRPHYSM2);
merge brfss1 brfss5;
I've already deleted the merge dataset file that was saved from the P drive and not by using SAS code. Yesterday like I said I had the same problem but it suddenly worked (don't have any clue how) and today I had the problem again.
(FYI by not seeing the data, I mean when I double click on it from the P or Q drive; the proc print works just fine)
04-07-2016 01:07 PM - edited 04-07-2016 01:08 PM
I don't see anything in the code that would cause what you describe.
In the last data step though:
merge brfss1 brfss5;
Is brfss5 what you mean to merge, or should it be brfss6?
This might cause unexpected results if same-name variables in brfss1 are overwritten.
04-07-2016 01:21 PM
Thank you LinusH. Yes the data sets are there and every thing seems fine but the tmp data ( when I just click on the data file from the P and Q driver) shows only the variable row and no observations. Proc contents, proc print, and proc freq all are working fine. Attached is the proc content.
And as I said yesterday I had the same problem but it worked at some point (I was deleting all dat sets that I saved recently on driver P when data showed again on both drives P and Q; I have no clue how and why) . Today I had the same problem again after I was manipulating, merging and saving the merged dataset on P. I deleted the new file but still have no data there.