good day,
here is the problem i can't solve
i have assigned a manual name to my data set as name
now i want to do some sample check,
can i randomly draw 5 results out for each name to Verify?
and i would like to place them in the same row like this
name || merchant_strip1 || merchant_strip2 || merchant_strip3 || merchant_strip4 ||merchant_strip5
here is my raw data set
merchant_strip | Name |
A A ALFA TAXI DI FIORI GENESTRERIOTICH | TAXI |
A A OPTICAL HONG KONG HKG | OPTICAL |
A A OPTICAL HONG KONG HKG | OPTICAL |
A A OPTICAL HONG KONG HK | OPTICAL |
A A OPTICAL YUEN LONG HK | OPTICAL |
A A OPTICAL YUEN LONG HKG | OPTICAL |
A AIRLINE TAXI MISSISSAUGA CAN | TAXI |
A AIX TAXI AIX EN PRO FR * | TAXI |
A ALEHOP AER VALENCIAMANISES ES | ALEHOP |
A B A L TOWING PTY L THORNLEIGH AUS | BURBERRY |
A B C DISCOUNT CARPETS CROWS NEST AU | CARPET |
A B SUPER MARCHE GHAZIABAD IN A B SUPER MARCH | SUPERMARCHE |
A BAGHLOUL TAXI GENEVE CH | TAXI |
A BAKERY CENTRAL | A BAKERY |
A BAKERY SHATIN | A BAKERY |
A BAKERY TAIKOO | A BAKERY |
A BAKERY SHATIN | A BAKERY |
A BAKERY C HKG HKG | A1 BAKERY |
A BAKERY CAFE HONGKONG HK | A1 BAKERY |
Regards,
Harry
data have; length group $1 j $15; do i=1 to 300; if i<=100 then group="A"; else if i <=200 then group="B"; else group="C"; j=cats("student",i); output; end; drop i; run; proc sort data=have; by group; run; proc surveyselect data=have out=Sample(keep=group j) method=srs n=(5 5 5) noprint; strata group; run; Proc transpose data=sample out=want(drop=_name_) prefix=student; by group; var j; run;
i hope that its what you want
proc surveyselect should be able to get the data, post-processing is required for the layout (maybe proc report with an across-variable).
Hi,
I didn’t quite understand your questions,
can you explain more details
with a copy of the output table please
Thanks.
The SELECTION part is Proc survey select. Your "grouping" variable would be a strata and you would need to sort the data set by that variable first.
Proc surveyselect data=have out=selected sampsize=5;
Strata groupvariablename;
run;
would select 5 records for each strata. Caution: what do you want if there are not at least 5 records for each and every group? The procedure has an option to select all available SELECTALL to get all of the values if there are fewer in the group than you specified in the SAMPSIZE option.
A worked example you should be able to run:
proc sort data=sashelp.class out=work.class; by sex; run; proc surveyselect data=work.class out=work.select sampsize=5; strata sex; run;
Then Transpose the resulting data set to get the across if really needed but the results will be grouped by the strata and since it seems like you are going to manually check something else for "accuracy" then the transpose may not be needed.
thanks all for help
data have; length group $1 j $15; do i=1 to 300; if i<=100 then group="A"; else if i <=200 then group="B"; else group="C"; j=cats("student",i); output; end; drop i; run; proc sort data=have; by group; run; proc surveyselect data=have out=Sample(keep=group j) method=srs n=(5 5 5) noprint; strata group; run; Proc transpose data=sample out=want(drop=_name_) prefix=student; by group; var j; run;
i hope that its what you want
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: