NewYorkBoraPL
10-13-2008, 01:52 AM
Hi
I wanted to see if someone could help me out with some syntax or at least point me in the right direction.
I have an ASCCI data set with about 1200 lines and want to use the information from my original source to create a new data set.
My original data set contains the variables "State" and "OFFLOC" where OFFLOC is the location of an office. There are a total of 10 states which have OFFLOC from 1-11. What I want, or need, to do it create a sas data set containing one record for each state and locoff combination.
I have created a two way frequency table for this to view the data and already know how many "locoff" there are in each state. I could rewrite the data step manually but I really would like to learn how to loop something like this.
Thanks.
prashant
10-13-2008, 06:05 PM
I am not sure wht you want
Guess1
proc sql;
create table bla as
Select State , OFFLOC
From bla_bla
group by State , OFFLOC
order byState , OFFLOC
;quit
gues2
proc sort data = bla out = bla_bla nodupkey; by *** **** State OFFLOC;run;
malone73
11-18-2008, 03:56 PM
Could you please clarify whether your original dataset is in a text file or whether you have already imported it into a SAS data set?
NewYorkBoraPL
12-09-2008, 10:07 PM
The dataset was a text file I had saved in note pad. I ended up doing it manually in excel and then using that information in SAS. I still am confused with coding and do loops.
Say for instance I had a file like so:
Data xwy;
input agegp fbday sfday canc ncanc;
datalines;
30 20 10 0 40
30 15 15 1 52
30 10 20 1 33
...................................
...................................
80 5 25 6 65
;
Where agegp is agegroup, fbday is fiber per day, sfday is saturated fat per day, canc is colan cancer, and ncanc is no colocancer.
I would like to get SAS to actually display all the records individually.
I.E in the first group there is a total number of 40 observations, where 40 have no cancer and 0 have cancer and in the very last line there are 71 observations where 65 have no cancer and 6 have cancer. In theory say there where 1500 observations summarized in the above code, how would I get sas to display each one of them individually in a list? Is the do loop a proper procedure?
Thanks
Mean Joe
12-24-2008, 08:37 PM
The dataset was a text file I had saved in note pad. I ended up doing it manually in excel and then using that information in SAS. I still am confused with coding and do loops.
Say for instance I had a file like so:
Data xwy;
input agegp fbday sfday canc ncanc;
datalines;
30 20 10 0 40
30 15 15 1 52
30 10 20 1 33
...................................
...................................
80 5 25 6 65
;
Where agegp is agegroup, fbday is fiber per day, sfday is saturated fat per day, canc is colan cancer, and ncanc is no colocancer.
I would like to get SAS to actually display all the records individually.
I.E in the first group there is a total number of 40 observations, where 40 have no cancer and 0 have cancer and in the very last line there are 71 observations where 65 have no cancer and 6 have cancer. In theory say there where 1500 observations summarized in the above code, how would I get sas to display each one of them individually in a list? Is the do loop a proper procedure?
Thanks
Let me get this straight: it sounds like you want the above dataset xwy with just a few lines to be expanded into 1500 lines (sum of canc+ncanc). You can do that with a DO loop and OUTPUT statements.
eg
data abc(drop=canc ncanc);
set xwy;
do i=1 to canc;
cancerflag=1; *creating a flag variable;
output;
end;
do i=1 to ncanc;
cancerflag=0;
output;
end;
run;